diff --git a/.gitignore b/.gitignore index 2f9595f68cdf8b6e340a6450b1313fe1b97b4dd6..be49e74eacab574fa1325517346af712eb242e24 100644 --- a/.gitignore +++ b/.gitignore @@ -8,9 +8,6 @@ # SPDX-License-Identifier: EPL-2.0 ################################################################################# -# m2e-code-quality Eclipse IDE plugin -.checkstyle - # Maven build folder **/bin/ **/target/ diff --git a/TRACE4CPS.setup b/TRACE4CPS.setup index ae331e4296abf5075a35fbdfc94ec3898fdc2918..812d06bf87c11207be1d75345a8bbdd4428310a5 100644 --- a/TRACE4CPS.setup +++ b/TRACE4CPS.setup @@ -80,6 +80,14 @@ + + + @@ -114,11 +122,11 @@ + value="19"/> + value="<?xml version="1.0" encoding="UTF-8" standalone="no"?> <profiles version="21"> <profile kind="CodeFormatterProfile" name="Eclipse TRACE4CPS profile" version="19"> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_ellipsis" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment" value="common_lines"/> <setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_logical_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation" value="common_lines"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_after_imports" value="1"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_record_declaration" value="common_lines"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement" value="common_lines"/> <setting id="org.eclipse.jdt.core.formatter.comment.format_javadoc_comments" value="true"/> <setting id="org.eclipse.jdt.core.formatter.indentation.size" value="4"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration" value="common_lines"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_default" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.align_with_spaces" value="false"/> <setting id="org.eclipse.jdt.core.formatter.disabling_tag" value="@formatter:off"/> <setting id="org.eclipse.jdt.core.formatter.continuation_indentation" value="2"/> <setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_before_code_block" value="0"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_switch_case_expressions" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_enum_constants" value="16"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_imports" value="1"/> <setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_method_body" value="-1"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_after_package" value="1"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement" value="common_lines"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.comment.indent_root_tags" value="false"/> <setting id="org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch" value="true"/> <setting id="org.eclipse.jdt.core.formatter.enabling_tag" value="@formatter:on"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position" value="false"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_record_components" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_case" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.wrap_before_multiplicative_operator" value="true"/> <setting id="org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line" value="false"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations" value="1"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references" value="0"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_logical_operator" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.keep_annotation_declaration_on_one_line" value="one_line_never"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_record_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_multiplicative_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column" value="false"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_block" value="true"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration" value="next_line_on_wrap"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.comment.align_tags_descriptions_grouped" value="false"/> <setting id="org.eclipse.jdt.core.formatter.comment.line_length" value="120"/> <setting id="org.eclipse.jdt.core.formatter.use_on_off_tags" value="true"/> <setting id="org.eclipse.jdt.core.formatter.keep_method_body_on_one_line" value="one_line_never"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.keep_loop_body_block_on_one_line" value="one_line_never"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments" value="false"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_method_declaration" value="next_line_on_wrap"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_abstract_method" value="1"/> <setting id="org.eclipse.jdt.core.formatter.keep_enum_constant_declaration_on_one_line" value="one_line_never"/> <setting id="org.eclipse.jdt.core.formatter.align_variable_declarations_on_columns" value="false"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.keep_type_declaration_on_one_line" value="one_line_never"/> <setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body" value="-1"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line" value="false"/> <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause" value="common_lines"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_additive_operator" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_constructor" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_relational_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_multiplicative_operator" value="16"/> <setting id="org.eclipse.jdt.core.formatter.keep_anonymous_type_declaration_on_one_line" value="one_line_never"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_switch_case_expressions" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.wrap_before_shift_operator" value="true"/> <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.keep_record_declaration_on_one_line" value="one_line_never"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_block" value="next_line_on_wrap"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration" value="next_line_on_wrap"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_lambda_body" value="next_line_on_wrap"/> <setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_end_of_code_block" value="-1"/> <setting id="org.eclipse.jdt.core.formatter.compact_else_if" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_bitwise_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line" value="true"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration" value="16"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_type_parameters" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation" value="16"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration" value="16"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_loops" value="16"/> <setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment" value="false"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.keep_simple_for_body_on_same_line" value="false"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment" value="false"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_relational_operator" value="0"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_unary_operator" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer" value="16"/> <setting id="org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column" value="false"/> <setting id="org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve" value="1"/> <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation" value="common_lines"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_ellipsis" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_additive_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_string_concatenation" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.comment.format_line_comments" value="true"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_declaration" value="next_line_on_wrap"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.text_block_indentation" value="0"/> <setting id="org.eclipse.jdt.core.formatter.align_type_members_on_columns" value="false"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_assignment" value="0"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_module_statements" value="16"/> <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_after_code_block" value="0"/> <setting id="org.eclipse.jdt.core.formatter.comment.align_tags_names_descriptions" value="false"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration" value="16"/> <setting id="org.eclipse.jdt.core.formatter.keep_if_then_body_block_on_one_line" value="one_line_never"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration" value="-1"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line" value="false"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.align_assignment_statements_on_columns" value="false"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration" value="next_line_on_wrap"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_block_in_case" value="next_line_on_wrap"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_arrow_in_switch_default" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.comment.insert_new_line_between_different_tags" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_conditional_expression_chain" value="0"/> <setting id="org.eclipse.jdt.core.formatter.comment.format_header" value="false"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_additive_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_method_declaration" value="16"/> <setting id="org.eclipse.jdt.core.formatter.join_wrapped_lines" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.wrap_before_conditional_operator" value="true"/> <setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_shift_operator" value="0"/> <setting id="org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines" value="2147483647"/> <setting id="org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries" value="true"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_bitwise_operator" value="16"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration" value="next_line_on_wrap"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_resources_in_try" value="82"/> <setting id="org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations" value="false"/> <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause" value="common_lines"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation" value="16"/> <setting id="org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column" value="false"/> <setting id="org.eclipse.jdt.core.formatter.keep_code_block_on_one_line" value="one_line_never"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_record_components" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.tabulation.size" value="4"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_bitwise_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.comment.format_source_code" value="false"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_field" value="1"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer" value="2"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_method" value="1"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_record_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.wrap_before_assignment_operator" value="false"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_not_operator" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_switch" value="next_line_on_wrap"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.comment.format_html" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration" value="common_lines"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_compact_if" value="16"/> <setting id="org.eclipse.jdt.core.formatter.keep_lambda_body_block_on_one_line" value="one_line_if_single_item"/> <setting id="org.eclipse.jdt.core.formatter.indent_empty_lines" value="false"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_type_arguments" value="0"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_unary_operator" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.keep_record_constructor_on_one_line" value="one_line_never"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_record_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line" value="true"/> <setting id="org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk" value="1"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_label" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_arrow_in_switch_case" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_member_type" value="1"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_logical_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_record_header" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression" value="16"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_record_declaration" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.wrap_before_bitwise_operator" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.wrap_before_relational_operator" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.comment.format_block_comments" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.comment.indent_tag_description" value="true"/> <setting id="org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line" value="false"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_record_constructor" value="next_line_on_wrap"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_string_concatenation" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_after_last_class_body_declaration" value="-1"/> <setting id="org.eclipse.jdt.core.formatter.indent_statements_compare_to_body" value="true"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_multiple_fields" value="16"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.keep_simple_while_body_on_same_line" value="false"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_array_initializer" value="next_line_on_wrap"/> <setting id="org.eclipse.jdt.core.formatter.wrap_before_logical_operator" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_shift_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_between_statement_group_in_switch" value="0"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration" value="separate_lines_if_wrapped"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_shift_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.keep_simple_do_while_body_on_same_line" value="false"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.keep_enum_declaration_on_one_line" value="one_line_never"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_record_components" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_enum_constant" value="next_line_on_wrap"/> <setting id="org.eclipse.jdt.core.formatter.brace_position_for_type_declaration" value="next_line_on_wrap"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_multiplicative_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_before_package" value="-2"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header" value="0"/> <setting id="org.eclipse.jdt.core.formatter.wrap_before_additive_operator" value="true"/> <setting id="org.eclipse.jdt.core.formatter.keep_simple_getter_setter_on_one_line" value="false"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_string_concatenation" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.join_lines_in_comments" value="true"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.comment.indent_parameter_description" value="true"/> <setting id="org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_code_block" value="-1"/> <setting id="org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_record_declaration" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.tabulation.char" value="space"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_relational_operator" value="insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.wrap_before_string_concatenation" value="true"/> <setting id="org.eclipse.jdt.core.formatter.blank_lines_between_import_groups" value="1"/> <setting id="org.eclipse.jdt.core.formatter.lineSplit" value="120"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation" value="do not insert"/> <setting id="org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch" value="insert"/> </profile> </profiles> "/> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + name="net.sf.eclipsecs.feature.group"/> + name="de.jcup.asciidoctoreditor.feature.group"/> + + + + + + diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/.project b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/.project index 7a38e7848d8b085dafd145749dbb33f1a6628145..eda9443b482f3412a7f3c537df5b21a2c916da49 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/.project +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/.project @@ -20,9 +20,15 @@ + + net.sf.eclipsecs.core.CheckstyleBuilder + + + org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + net.sf.eclipsecs.core.CheckstyleNature diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/JFreeChartUIPlugin.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/JFreeChartUIPlugin.java index c73d60c9d9d0c6e97ca0b9d32e0458db6edd08a9..ad920dd730a2873b026390e28fd5eb320a54573d 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/JFreeChartUIPlugin.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/JFreeChartUIPlugin.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.ui; import static org.eclipse.core.runtime.IStatus.ERROR; @@ -32,8 +33,7 @@ public class JFreeChartUIPlugin extends AbstractUIPlugin { // The plug-in ID public static final String PLUGIN_ID = "org.eclipse.trace4cps.common.jfreechart.ui"; //$NON-NLS-1$ - private static final String EXTENSION_CHART_THEME_SUPPLIER = PLUGIN_ID - + ".chartthemesupplier"; + private static final String EXTENSION_CHART_THEME_SUPPLIER = PLUGIN_ID + ".chartthemesupplier"; // The shared instance private static JFreeChartUIPlugin plugin; @@ -56,12 +56,11 @@ public class JFreeChartUIPlugin extends AbstractUIPlugin { private void configureLookAndFeel() { try { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - } catch (ClassNotFoundException | InstantiationException - | IllegalAccessException | UnsupportedLookAndFeelException e) { + } catch (ClassNotFoundException | InstantiationException | IllegalAccessException + | UnsupportedLookAndFeelException e) + { IStatus status = new Status(ERROR, PLUGIN_ID, - "Failed to install system look-and-feel: " - + e.getLocalizedMessage(), - e); + "Failed to install system look-and-feel: " + e.getLocalizedMessage(), e); getLog().log(status); } } @@ -71,14 +70,13 @@ public class JFreeChartUIPlugin extends AbstractUIPlugin { .getConfigurationElementsFor(EXTENSION_CHART_THEME_SUPPLIER); int highestRank = Integer.MIN_VALUE; IConfigurationElement highestElement = null; - for (IConfigurationElement element : elements) { + for (IConfigurationElement element: elements) { if (!"chart_theme_supplier".equals(element.getName())) { continue; } String rankStr = element.getAttribute("rank"); if (null == rankStr) { - IStatus status = new Status(ERROR, - element.getContributor().getName(), + IStatus status = new Status(ERROR, element.getContributor().getName(), "Chart theme supplier is missing mandatory attribute 'rank'"); getLog().log(status); } @@ -89,22 +87,18 @@ public class JFreeChartUIPlugin extends AbstractUIPlugin { highestElement = element; } } catch (NumberFormatException e) { - IStatus status = new Status(ERROR, - element.getContributor().getName(), - "Chart theme supplier attribute 'rank' not a valid integer", - e); + IStatus status = new Status(ERROR, element.getContributor().getName(), + "Chart theme supplier attribute 'rank' not a valid integer", e); getLog().log(status); } } if (null != highestElement) { try { - ChartThemeSupplier supplier = (ChartThemeSupplier) highestElement - .createExecutableExtension("class"); + ChartThemeSupplier supplier = (ChartThemeSupplier)highestElement.createExecutableExtension("class"); ChartFactory.setChartTheme(supplier.getChartTheme()); } catch (CoreException e) { - IStatus status = new Status(ERROR, - highestElement.getContributor().getName(), + IStatus status = new Status(ERROR, highestElement.getContributor().getName(), "Chart theme supplier could not be instantiated", e); getLog().log(status); } @@ -125,5 +119,4 @@ public class JFreeChartUIPlugin extends AbstractUIPlugin { public static JFreeChartUIPlugin getDefault() { return plugin; } - } diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/gantt/XYGanttDataItem.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/gantt/XYGanttDataItem.java index 89bff77d45d82e227ae3b64db76fb25c0988389d..d6b5d05514d15666bfb8c1706c553a10efe76f84 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/gantt/XYGanttDataItem.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/gantt/XYGanttDataItem.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.ui.gantt; import static org.jfree.chart.plot.PlotOrientation.VERTICAL; @@ -18,12 +19,13 @@ import org.jfree.chart.plot.PlotOrientation; import org.jfree.data.Range; import org.jfree.data.xy.XYIntervalDataItem; -public class XYGanttDataItem extends XYIntervalDataItem - implements BackReferenceProvider { +public class XYGanttDataItem extends XYIntervalDataItem implements BackReferenceProvider { private static final long serialVersionUID = 3004235510100651118L; public static final double DEFAULT_OCCUPATION = 0.9; + public static final double DEFAULT_OFFSET = 0.05; + public static final double DEFAULT_RESOURCE_LENGTH = 1; private final transient T backReference; @@ -32,39 +34,35 @@ public class XYGanttDataItem extends XYIntervalDataItem this(calculateResourceRange(resourceIndex), start, end); } - public XYGanttDataItem(Number resourceIndex, Number start, Number end, - T backReference) { + public XYGanttDataItem(Number resourceIndex, Number start, Number end, T backReference) { this(calculateResourceRange(resourceIndex), start, end, backReference); } - public XYGanttDataItem(Number resourceIndex, Number resourceOccupation, - Number resourceOffset, Number start, Number end, - PlotOrientation orientation, T backReference) { - this(calculateResourceRange(resourceIndex), resourceOccupation, - resourceOffset, start, end, orientation, backReference); + public XYGanttDataItem(Number resourceIndex, Number resourceOccupation, Number resourceOffset, Number start, + Number end, PlotOrientation orientation, T backReference) + { + this(calculateResourceRange(resourceIndex), resourceOccupation, resourceOffset, start, end, orientation, + backReference); } public XYGanttDataItem(Range resourceRange, Number start, Number end) { - this(resourceRange, DEFAULT_OCCUPATION, DEFAULT_OFFSET, start, end, - VERTICAL, null); + this(resourceRange, DEFAULT_OCCUPATION, DEFAULT_OFFSET, start, end, VERTICAL, null); } - public XYGanttDataItem(Range resourceRange, Number start, Number end, - T backReference) { - this(resourceRange, DEFAULT_OCCUPATION, DEFAULT_OFFSET, start, end, - VERTICAL, backReference); + public XYGanttDataItem(Range resourceRange, Number start, Number end, T backReference) { + this(resourceRange, DEFAULT_OCCUPATION, DEFAULT_OFFSET, start, end, VERTICAL, backReference); } - public XYGanttDataItem(Range resourceRange, Number resourceOccupation, - Number resourceOffset, Number start, Number end, - PlotOrientation orientation, T backReference) { - this(calculateBounds(resourceRange, resourceOccupation, resourceOffset, - start, end, orientation), backReference); + public XYGanttDataItem(Range resourceRange, Number resourceOccupation, Number resourceOffset, Number start, + Number end, PlotOrientation orientation, T backReference) + { + this(calculateBounds(resourceRange, resourceOccupation, resourceOffset, start, end, orientation), + backReference); } private XYGanttDataItem(Rectangle2D bounds, T backReference) { - super(bounds.getCenterX(), bounds.getMinX(), bounds.getMaxX(), - bounds.getCenterY(), bounds.getMinY(), bounds.getMaxY()); + super(bounds.getCenterX(), bounds.getMinX(), bounds.getMaxX(), bounds.getCenterY(), bounds.getMinY(), + bounds.getMaxY()); this.backReference = backReference; } @@ -75,13 +73,12 @@ public class XYGanttDataItem extends XYIntervalDataItem return new Range(lower, upper); } - private static Rectangle2D calculateBounds(Range resourceRange, - Number occupation, Number offset, Number start, Number end, - PlotOrientation orientation) { + private static Rectangle2D calculateBounds(Range resourceRange, Number occupation, Number offset, Number start, + Number end, PlotOrientation orientation) + { double x = start.doubleValue(); double w = end.doubleValue() - start.doubleValue(); - double y = resourceRange.getLowerBound() - + (offset.doubleValue() * resourceRange.getLength()); + double y = resourceRange.getLowerBound() + (offset.doubleValue() * resourceRange.getLength()); double h = occupation.doubleValue() * resourceRange.getLength(); if (PlotOrientation.VERTICAL == orientation) { return new Rectangle2D.Double(x, y, w, h); diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/gantt/XYGanttDependencyItem.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/gantt/XYGanttDependencyItem.java index 06b3740e533e702cd4c88782cfb0d7803e989e5f..abbefad5057d82c366e1bfda20037b0df624db42 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/gantt/XYGanttDependencyItem.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/gantt/XYGanttDependencyItem.java @@ -7,49 +7,50 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.ui.gantt; import org.eclipse.trace4cps.common.jfreechart.data.xy.XYEdgeDataItem; import org.eclipse.trace4cps.common.jfreechart.ui.viewers.BackReferenceProvider; public class XYGanttDependencyItem extends XYEdgeDataItem implements BackReferenceProvider { - private static final long serialVersionUID = -2205873637869057094L; - - public enum DependencyType { - START_START(true, true), START_END(true, false), END_START(false, true), END_END(false, false); - private final boolean fromStart; - private final boolean toStart; - - private DependencyType(boolean fromStart, boolean toStart) { - this.fromStart = fromStart; - this.toStart = toStart; - } - - public boolean isFromStart() { - return fromStart; - } - - public boolean isToStart() { - return toStart; - } - }; - - private final transient T backReference; - - public XYGanttDependencyItem(XYGanttDataItem from, XYGanttDataItem to, DependencyType type) { - this(from, to, type, null); - } - - public XYGanttDependencyItem(XYGanttDataItem from, XYGanttDataItem to, DependencyType type, T backReference) { - super(type.isFromStart() ? from.getXLowValue() : from.getXHighValue(), - from.getYValue(), - type.isToStart() ? to.getXLowValue() : to.getXHighValue(), - to.getYValue()); - this.backReference = backReference; - } - - @Override - public T getBackReference() { - return backReference; - } + private static final long serialVersionUID = -2205873637869057094L; + + public enum DependencyType { + START_START(true, true), START_END(true, false), END_START(false, true), END_END(false, false); + + private final boolean fromStart; + + private final boolean toStart; + + private DependencyType(boolean fromStart, boolean toStart) { + this.fromStart = fromStart; + this.toStart = toStart; + } + + public boolean isFromStart() { + return fromStart; + } + + public boolean isToStart() { + return toStart; + } + } + + private final transient T backReference; + + public XYGanttDependencyItem(XYGanttDataItem from, XYGanttDataItem to, DependencyType type) { + this(from, to, type, null); + } + + public XYGanttDependencyItem(XYGanttDataItem from, XYGanttDataItem to, DependencyType type, T backReference) { + super(type.isFromStart() ? from.getXLowValue() : from.getXHighValue(), from.getYValue(), + type.isToStart() ? to.getXLowValue() : to.getXHighValue(), to.getYValue()); + this.backReference = backReference; + } + + @Override + public T getBackReference() { + return backReference; + } } diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/gantt/XYGanttMeasurement.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/gantt/XYGanttMeasurement.java index 584df0d62621533194abba286f829d0e7007bf08..24550863d1ef1d49b1c82fb05eed592ea58f0eb8 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/gantt/XYGanttMeasurement.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/gantt/XYGanttMeasurement.java @@ -7,64 +7,61 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.ui.gantt; public interface XYGanttMeasurement { - public enum Snap { - START, END - }; + public enum Snap { + START, END + } + + /** + * We do not assume measurements going from left to right or low to high, etc. We only know the first and second + * item which where selected for this measurement, hence the name of this method. + * + * @return a reference to the first measurement item + */ + T getBackReference1(); - /** - * We do not assume measurements going from left to right or low to high, etc. - * We only know the first and second item which where selected for this - * measurement, hence the name of this method. - * - * @return a reference to the first measurement item - */ - T getBackReference1(); + /** + * @return if the measurement is either from/to the start or the end of the first measurement item. + * @see #getBackReference1() + */ + Snap getSnap1(); - /** - * @return if the measurement is either from/to the start or the end of the - * first measurement item. - * @see #getBackReference1() - */ - Snap getSnap1(); + /** + * @return the time of the first selection. + */ + Number getTime1(); - /** - * @return the time of the first selection. - */ - Number getTime1(); + /** + * We do not assume measurements going from left to right or low to high, etc. We only know the first and second + * item which where selected for this measurement, hence the name of this method. + * + * @return a reference to the second measurement item + */ + T getBackReference2(); - /** - * We do not assume measurements going from left to right or low to high, etc. - * We only know the first and second item which where selected for this - * measurement, hence the name of this method. - * - * @return a reference to the second measurement item - */ - T getBackReference2(); + /** + * @return if the measurement is either from/to the start or the end of the second measurement item. + * @see #getBackReference2() + */ + Snap getSnap2(); - /** - * @return if the measurement is either from/to the start or the end of the - * second measurement item. - * @see #getBackReference2() - */ - Snap getSnap2(); + /** + * @return the time of the second selection. + */ + Number getTime2(); - /** - * @return the time of the second selection. - */ - Number getTime2(); + /** + * @return the absolute duration between the two measurement points. + */ + Number getDuration(); - /** - * @return the absolute duration between the two measurement points. - */ - Number getDuration(); - - /** - * @return the text that describes this measurement - */ - default String getText() { - return String.valueOf(getDuration()); - } + /** + * @return the text that describes this measurement + */ + default String getText() { + return String.valueOf(getDuration()); + } } diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/gantt/XYGanttMeasurementAnnotation.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/gantt/XYGanttMeasurementAnnotation.java index 31a994beb24915d78f8bb3f8b9ab64d330507d33..567cec2c25f025bba159ba0240fbafd1ec476106 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/gantt/XYGanttMeasurementAnnotation.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/gantt/XYGanttMeasurementAnnotation.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.ui.gantt; import java.math.BigDecimal; @@ -14,104 +15,109 @@ import java.math.BigDecimal; import org.eclipse.trace4cps.common.jfreechart.ui.viewers.BackReferenceProvider; import org.jfree.chart.annotations.XYMeasurementAnnotation; -public class XYGanttMeasurementAnnotation extends XYMeasurementAnnotation implements XYGanttMeasurement, BackReferenceProvider> { - private static final long serialVersionUID = -5836943007613577145L; - - private final XYGanttMeasurementAnnotationDescriptor descriptor = new XYGanttMeasurementAnnotationDescriptor(this); - private final XYGanttDataItem item1; - private final Snap snap1; - private final XYGanttDataItem item2; - private final Snap snap2; - - public XYGanttMeasurementAnnotation(Orientation orientation, String label, XYGanttDataItem item1, Snap snap1, XYGanttDataItem item2, - Snap snap2) { - super(orientation, label, - snap1 == Snap.START ? item1.getXLowValue() : item1.getXHighValue(), - item1.getYValue(), - snap2 == Snap.START ? item2.getXLowValue() : item2.getXHighValue(), - item2.getYValue()); - setBaseCreateEntity(true); - this.item1 = item1; - this.snap1 = snap1; - this.item2 = item2; - this.snap2 = snap2; - } - - @Override - public XYGanttMeasurementAnnotationDescriptor getBackReference() { - return descriptor; - } - - @Override - public T getBackReference1() { - return item1.getBackReference(); - } - - @Override - public T getBackReference2() { - return item2.getBackReference(); - } - - @Override - public Snap getSnap1() { - return snap1; - } - - @Override - public Snap getSnap2() { - return snap2; - } - - @Override - public Number getTime1() { - return getX(); - } - - @Override - public Number getTime2() { - return getX2(); - } - - @Override - public Number getDuration() { - // Try to avoid rounding errors as much as possible - return BigDecimal.valueOf(getX2()).subtract(BigDecimal.valueOf(getX())).abs(); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = super.hashCode(); - result = prime * result + ((item1 == null) ? 0 : item1.hashCode()); - result = prime * result + ((item2 == null) ? 0 : item2.hashCode()); - result = prime * result + ((snap1 == null) ? 0 : snap1.hashCode()); - result = prime * result + ((snap2 == null) ? 0 : snap2.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (!super.equals(obj)) - return false; - if (getClass() != obj.getClass()) - return false; - XYGanttMeasurementAnnotation other = (XYGanttMeasurementAnnotation) obj; - if (item1 == null) { - if (other.item1 != null) - return false; - } else if (!item1.equals(other.item1)) - return false; - if (item2 == null) { - if (other.item2 != null) - return false; - } else if (!item2.equals(other.item2)) - return false; - if (snap1 != other.snap1) - return false; - if (snap2 != other.snap2) - return false; - return true; - } +public class XYGanttMeasurementAnnotation extends XYMeasurementAnnotation + implements XYGanttMeasurement, BackReferenceProvider> +{ + private static final long serialVersionUID = -5836943007613577145L; + + private final XYGanttMeasurementAnnotationDescriptor descriptor = new XYGanttMeasurementAnnotationDescriptor( + this); + + private final XYGanttDataItem item1; + + private final Snap snap1; + + private final XYGanttDataItem item2; + + private final Snap snap2; + + public XYGanttMeasurementAnnotation(Orientation orientation, String label, XYGanttDataItem item1, + Snap snap1, XYGanttDataItem item2, Snap snap2) + { + super(orientation, label, snap1 == Snap.START ? item1.getXLowValue() : item1.getXHighValue(), item1.getYValue(), + snap2 == Snap.START ? item2.getXLowValue() : item2.getXHighValue(), item2.getYValue()); + setBaseCreateEntity(true); + this.item1 = item1; + this.snap1 = snap1; + this.item2 = item2; + this.snap2 = snap2; + } + + @Override + public XYGanttMeasurementAnnotationDescriptor getBackReference() { + return descriptor; + } + + @Override + public T getBackReference1() { + return item1.getBackReference(); + } + + @Override + public T getBackReference2() { + return item2.getBackReference(); + } + + @Override + public Snap getSnap1() { + return snap1; + } + + @Override + public Snap getSnap2() { + return snap2; + } + + @Override + public Number getTime1() { + return getX(); + } + + @Override + public Number getTime2() { + return getX2(); + } + + @Override + public Number getDuration() { + // Try to avoid rounding errors as much as possible + return BigDecimal.valueOf(getX2()).subtract(BigDecimal.valueOf(getX())).abs(); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = super.hashCode(); + result = prime * result + ((item1 == null) ? 0 : item1.hashCode()); + result = prime * result + ((item2 == null) ? 0 : item2.hashCode()); + result = prime * result + ((snap1 == null) ? 0 : snap1.hashCode()); + result = prime * result + ((snap2 == null) ? 0 : snap2.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) + return true; + if (!super.equals(obj)) + return false; + if (getClass() != obj.getClass()) + return false; + XYGanttMeasurementAnnotation other = (XYGanttMeasurementAnnotation)obj; + if (item1 == null) { + if (other.item1 != null) + return false; + } else if (!item1.equals(other.item1)) + return false; + if (item2 == null) { + if (other.item2 != null) + return false; + } else if (!item2.equals(other.item2)) + return false; + if (snap1 != other.snap1) + return false; + if (snap2 != other.snap2) + return false; + return true; + } } diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/gantt/XYGanttMeasurementAnnotationDescriptor.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/gantt/XYGanttMeasurementAnnotationDescriptor.java index ffe186bfd0733e875d31907c14160dc9f3292676..9f071a65b6f0f14325a1d0e3226f5fc5b910f6e7 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/gantt/XYGanttMeasurementAnnotationDescriptor.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/gantt/XYGanttMeasurementAnnotationDescriptor.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.ui.gantt; import org.eclipse.ui.views.properties.IPropertyDescriptor; @@ -15,93 +16,97 @@ import org.eclipse.ui.views.properties.PropertyDescriptor; import org.eclipse.ui.views.properties.TextPropertyDescriptor; class XYGanttMeasurementAnnotationDescriptor implements IPropertySource, XYGanttMeasurement { - private enum Properties { Label, Duration }; - - private final XYGanttMeasurementAnnotation annotation; - - private IPropertyDescriptor[] propertyDescriptors; - - public XYGanttMeasurementAnnotationDescriptor(XYGanttMeasurementAnnotation annotation) { - this.annotation = annotation; - } - - @Override - public Object getEditableValue() { - return this; - } - - @Override - public IPropertyDescriptor[] getPropertyDescriptors() { - if (null == propertyDescriptors) { - TextPropertyDescriptor labelProperty = new TextPropertyDescriptor(Properties.Label, Properties.Label.name()); - PropertyDescriptor durationProperty = new PropertyDescriptor(Properties.Duration, Properties.Duration.name()); - propertyDescriptors = new IPropertyDescriptor[] { labelProperty, durationProperty }; - } - return propertyDescriptors; - } - - @Override - public Object getPropertyValue(Object id) { - switch ((XYGanttMeasurementAnnotationDescriptor.Properties) id) { - case Label: - return annotation.getText(); - case Duration: - return annotation.getDuration(); - } - return null; - } - - @Override - public boolean isPropertySet(Object id) { - return true; - } - - @Override - public void resetPropertyValue(Object id) { - if (id == Properties.Label) { - annotation.setText(""); - } - } - - @Override - public void setPropertyValue(Object id, Object value) { - if (id == Properties.Label) { - annotation.setText(String.valueOf(value)); - } - } - - @Override - public T getBackReference1() { - return annotation.getBackReference1(); - } - - @Override - public Snap getSnap1() { - return annotation.getSnap1(); - } - - @Override - public Number getTime1() { - return annotation.getTime1(); - } - - @Override - public T getBackReference2() { - return annotation.getBackReference2(); - } - - @Override - public Snap getSnap2() { - return annotation.getSnap2(); - } - - @Override - public Number getTime2() { - return annotation.getTime2(); - } - - @Override - public Number getDuration() { - return annotation.getDuration(); - } -} \ No newline at end of file + private enum Properties { + Label, Duration + } + + private final XYGanttMeasurementAnnotation annotation; + + private IPropertyDescriptor[] propertyDescriptors; + + public XYGanttMeasurementAnnotationDescriptor(XYGanttMeasurementAnnotation annotation) { + this.annotation = annotation; + } + + @Override + public Object getEditableValue() { + return this; + } + + @Override + public IPropertyDescriptor[] getPropertyDescriptors() { + if (null == propertyDescriptors) { + TextPropertyDescriptor labelProperty = new TextPropertyDescriptor(Properties.Label, + Properties.Label.name()); + PropertyDescriptor durationProperty = new PropertyDescriptor(Properties.Duration, + Properties.Duration.name()); + propertyDescriptors = new IPropertyDescriptor[] {labelProperty, durationProperty}; + } + return propertyDescriptors; + } + + @Override + public Object getPropertyValue(Object id) { + switch ((XYGanttMeasurementAnnotationDescriptor.Properties)id) { + case Label: + return annotation.getText(); + case Duration: + return annotation.getDuration(); + } + return null; + } + + @Override + public boolean isPropertySet(Object id) { + return true; + } + + @Override + public void resetPropertyValue(Object id) { + if (id == Properties.Label) { + annotation.setText(""); + } + } + + @Override + public void setPropertyValue(Object id, Object value) { + if (id == Properties.Label) { + annotation.setText(String.valueOf(value)); + } + } + + @Override + public T getBackReference1() { + return annotation.getBackReference1(); + } + + @Override + public Snap getSnap1() { + return annotation.getSnap1(); + } + + @Override + public Number getTime1() { + return annotation.getTime1(); + } + + @Override + public T getBackReference2() { + return annotation.getBackReference2(); + } + + @Override + public Snap getSnap2() { + return annotation.getSnap2(); + } + + @Override + public Number getTime2() { + return annotation.getTime2(); + } + + @Override + public Number getDuration() { + return annotation.getDuration(); + } +} diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/internal/ChartPanelFactory.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/internal/ChartPanelFactory.java index 8146b1cbcea2ff61a5935c4d9de935857fd9e545..7717a938e7d2feb7512d4fd47d600e8db3d8e3a1 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/internal/ChartPanelFactory.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/internal/ChartPanelFactory.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.ui.internal; import java.awt.event.InputEvent; @@ -28,7 +29,7 @@ public class ChartPanelFactory { public static ChartPanel createChartPanel(JFreeChart chart) { return configureChartPanel(new OfflineRenderingChartPanel(chart)); } - + public static ChartPanel configureChartPanel(ChartPanel chartPanel) { chartPanel.setZoomAroundAnchor(true); chartPanel.setZoomOutFactor(1.25); diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/internal/ChartPanelScrollbarHandler.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/internal/ChartPanelScrollbarHandler.java index 6d6746d1c51457d6dc597f08dff46529900914aa..baebeaf538f27faac748ee3d3fecd111c1055fd8 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/internal/ChartPanelScrollbarHandler.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/internal/ChartPanelScrollbarHandler.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.ui.internal; import static org.eclipse.core.runtime.IStatus.WARNING; @@ -36,21 +37,24 @@ import org.jfree.chart.plot.PlotOrientation; import org.jfree.chart.plot.XYPlot; import org.jfree.data.Range; -public class ChartPanelScrollbarHandler extends SelectionAdapter - implements PropertyChangeListener, PlotChangeListener { +public class ChartPanelScrollbarHandler extends SelectionAdapter implements PropertyChangeListener, PlotChangeListener { // Numbers bigger than this lead to unwanted scrollbar behavior // i.e. sometimes the scroll direction changes when using the mouse wheel - private static int SCROLLBAR_LENGTH = 50_000_000; + private static final int SCROLLBAR_LENGTH = 50_000_000; private final Map axesAutoRanges = new WeakHashMap<>(); + private final ChartPanelComposite chartPanelComposite; private double incrementFactor = 0.1; + private double pageIncrementFactor = 0.9; private XYPlot currentPlot; + private Range lastDomainRange; + private Range lastRangeRange; public ChartPanelScrollbarHandler(ChartPanelComposite composite) { @@ -75,8 +79,7 @@ public class ChartPanelScrollbarHandler extends SelectionAdapter public void dispose() { boolean scroll = false; if (null != chartPanelComposite.getHorizontalBar()) { - chartPanelComposite.getHorizontalBar() - .removeSelectionListener(this); + chartPanelComposite.getHorizontalBar().removeSelectionListener(this); scroll = true; } if (null != chartPanelComposite.getVerticalBar()) { @@ -85,8 +88,7 @@ public class ChartPanelScrollbarHandler extends SelectionAdapter } if (scroll) { setChart(null); - chartPanelComposite.getChartPanel() - .removePropertyChangeListener(this); + chartPanelComposite.getChartPanel().removePropertyChangeListener(this); } } @@ -109,7 +111,7 @@ public class ChartPanelScrollbarHandler extends SelectionAdapter @Override public void propertyChange(PropertyChangeEvent event) { if (ChartPanel.PROPERTY_CHART.equals(event.getPropertyName())) { - setChart((JFreeChart) event.getNewValue()); + setChart((JFreeChart)event.getNewValue()); } } @@ -118,7 +120,7 @@ public class ChartPanelScrollbarHandler extends SelectionAdapter currentPlot.removeChangeListener(this); } if (null != chart && chart.getPlot() instanceof XYPlot) { - currentPlot = (XYPlot) chart.getPlot(); + currentPlot = (XYPlot)chart.getPlot(); currentPlot.addChangeListener(this); } currentPlotChanged(); @@ -134,17 +136,14 @@ public class ChartPanelScrollbarHandler extends SelectionAdapter private void currentPlotChanged() { boolean autoRangesChanged = cacheAutoRanges(); - ValueAxis domainAxis = null == currentPlot ? null - : currentPlot.getDomainAxis(); + ValueAxis domainAxis = null == currentPlot ? null : currentPlot.getDomainAxis(); if (null != domainAxis) { final Range domainRange = domainAxis.getRange(); - if (autoRangesChanged - || !Objects.equals(domainRange, lastDomainRange)) { + if (autoRangesChanged || !Objects.equals(domainRange, lastDomainRange)) { lastDomainRange = domainRange; final Range domainAutoRange = axesAutoRanges.get(domainAxis); if (null != domainAutoRange) { - updateScrollBar(this::getDomainBar, domainRange, - domainAutoRange); + updateScrollBar(this::getDomainBar, domainRange, domainAutoRange); } else { IStatus status = new Status(WARNING, PLUGIN_ID, "Skipped update: Unknown auto range for domain axis"); @@ -155,17 +154,14 @@ public class ChartPanelScrollbarHandler extends SelectionAdapter disableScrollBar(this::getDomainBar); } - ValueAxis rangeAxis = null == currentPlot ? null - : currentPlot.getRangeAxis(); + ValueAxis rangeAxis = null == currentPlot ? null : currentPlot.getRangeAxis(); if (null != rangeAxis) { final Range rangeRange = rangeAxis.getRange(); - if (autoRangesChanged - || !Objects.equals(rangeRange, lastRangeRange)) { + if (autoRangesChanged || !Objects.equals(rangeRange, lastRangeRange)) { lastRangeRange = rangeRange; final Range rangeAutoRange = axesAutoRanges.get(rangeAxis); if (null != rangeAutoRange) { - updateScrollBar(this::getRangeBar, rangeRange, - rangeAutoRange); + updateScrollBar(this::getRangeBar, rangeRange, rangeAutoRange); } else { IStatus status = new Status(WARNING, PLUGIN_ID, "Skipped update: Unknown auto range for range axis"); @@ -180,25 +176,20 @@ public class ChartPanelScrollbarHandler extends SelectionAdapter private void disableScrollBar(final Supplier scrollBarSupplier) { chartPanelComposite.getDisplay().asyncExec(() -> { ScrollBar scrollBar = scrollBarSupplier.get(); - if (scrollBar != null && !scrollBar.isDisposed() - && scrollBar.isEnabled()) { + if (scrollBar != null && !scrollBar.isDisposed() && scrollBar.isEnabled()) { scrollBar.setEnabled(false); } }); } - private void updateScrollBar(final Supplier scrollBarSupplier, - Range viewRange, Range autoRange) { + private void updateScrollBar(final Supplier scrollBarSupplier, Range viewRange, Range autoRange) { chartPanelComposite.getDisplay().asyncExec(() -> { ScrollBar scrollBar = scrollBarSupplier.get(); if (null == scrollBar || scrollBar.isDisposed()) { return; } - SCROLLBAR_LENGTH = 50_000_000; - - double thumbPercentage = viewRange.getLength() - / autoRange.getLength(); + double thumbPercentage = viewRange.getLength() / autoRange.getLength(); double thumb = thumbPercentage * SCROLLBAR_LENGTH; boolean enabled = thumb >= 1 && thumb < SCROLLBAR_LENGTH; scrollBar.setEnabled(enabled); @@ -208,8 +199,8 @@ public class ChartPanelScrollbarHandler extends SelectionAdapter double increment = Math.max(thumb * incrementFactor, 1); double pageIncrement = Math.max(thumb * pageIncrementFactor, 1); - double selectionPercentage = (viewRange.getLowerBound() - - autoRange.getLowerBound()) / autoRange.getLength(); + double selectionPercentage = (viewRange.getLowerBound() - autoRange.getLowerBound()) + / autoRange.getLength(); double selection = selectionPercentage * SCROLLBAR_LENGTH; if (selection < 0) { selection = 0; @@ -221,8 +212,8 @@ public class ChartPanelScrollbarHandler extends SelectionAdapter selection = SCROLLBAR_LENGTH - selection - thumb; } - scrollBar.setValues(round(selection), 0, SCROLLBAR_LENGTH, - round(thumb), round(increment), round(pageIncrement)); + scrollBar.setValues(round(selection), 0, SCROLLBAR_LENGTH, round(thumb), round(increment), + round(pageIncrement)); }); } @@ -242,14 +233,14 @@ public class ChartPanelScrollbarHandler extends SelectionAdapter for (int i = 0; i < currentPlot.getDomainAxisCount(); i++) { final ValueAxis domainAxis = currentPlot.getDomainAxis(i); if (domainAxis != null) { - updateAxisRange((ScrollBar) source, domainAxis); + updateAxisRange((ScrollBar)source, domainAxis); } } } else if (source == getRangeBar()) { for (int i = 0; i < currentPlot.getRangeAxisCount(); i++) { final ValueAxis rangeAxis = currentPlot.getRangeAxis(i); if (rangeAxis != null) { - updateAxisRange((ScrollBar) source, rangeAxis); + updateAxisRange((ScrollBar)source, rangeAxis); } } } @@ -262,9 +253,9 @@ public class ChartPanelScrollbarHandler extends SelectionAdapter } Range autoRange = axesAutoRanges.get(axis); if (null == autoRange) { - IStatus status = new Status(WARNING, PLUGIN_ID, String.format( - "Skipped update: Unknown auto range for axis: %s (type: %s)", - axis.getLabel(), axis.getClass().getName())); + IStatus status = new Status(WARNING, PLUGIN_ID, + String.format("Skipped update: Unknown auto range for axis: %s (type: %s)", axis.getLabel(), + axis.getClass().getName())); JFreeChartUIPlugin.getDefault().getLog().log(status); return; } @@ -279,8 +270,7 @@ public class ChartPanelScrollbarHandler extends SelectionAdapter double selectionPercentage = selection / length; double thumbPercentage = thumb / length; - double lower = autoRange.getLowerBound() - + (selectionPercentage * autoRange.getLength()); + double lower = autoRange.getLowerBound() + (selectionPercentage * autoRange.getLength()); double upper = lower + (thumbPercentage * autoRange.getLength()); axis.setRange(new Range(lower, upper), true, true); } @@ -312,24 +302,23 @@ public class ChartPanelScrollbarHandler extends SelectionAdapter */ protected boolean cacheAutoRange(ValueAxis axis) { Range newRange = axis.calculateAutoRange(false); - Range oldRange = null == newRange ? axesAutoRanges.remove(axis) - : axesAutoRanges.put(axis, newRange); + Range oldRange = null == newRange ? axesAutoRanges.remove(axis) : axesAutoRanges.put(axis, newRange); return !Objects.equals(oldRange, newRange); } protected ScrollBar getDomainBar() { - if (null == currentPlot) + if (null == currentPlot) { return null; - return currentPlot.getOrientation() == PlotOrientation.VERTICAL - ? chartPanelComposite.getHorizontalBar() + } + return currentPlot.getOrientation() == PlotOrientation.VERTICAL ? chartPanelComposite.getHorizontalBar() : chartPanelComposite.getVerticalBar(); } protected ScrollBar getRangeBar() { - if (null == currentPlot) + if (null == currentPlot) { return null; - return currentPlot.getOrientation() == PlotOrientation.VERTICAL - ? chartPanelComposite.getVerticalBar() + } + return currentPlot.getOrientation() == PlotOrientation.VERTICAL ? chartPanelComposite.getVerticalBar() : chartPanelComposite.getHorizontalBar(); } } diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/internal/DefaultChartThemeSupplier.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/internal/DefaultChartThemeSupplier.java index b774529f2de458a36a0e9af5b1b4758b2645720e..a4ca789f24a71a602fdc233ddfc23834cbdbf8e4 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/internal/DefaultChartThemeSupplier.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/internal/DefaultChartThemeSupplier.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.ui.internal; import org.eclipse.trace4cps.common.jfreechart.ui.theme.ChartThemeSupplier; diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/theme/ChartThemeSupplier.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/theme/ChartThemeSupplier.java index 185cd87eb113108d87f453871610b01bdcc0446b..3e40436f18cb26d2eef9345f0baa22040f67800c 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/theme/ChartThemeSupplier.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/theme/ChartThemeSupplier.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.ui.theme; import org.jfree.chart.ChartTheme; diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/theme/DefaultChartTheme.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/theme/DefaultChartTheme.java index b1cf6cd1df13abdc2b43a307028a1345d48d9139..14d9c8f845157aa98deb9cfbbcf6bc5dedee414c 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/theme/DefaultChartTheme.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/theme/DefaultChartTheme.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.ui.theme; import java.awt.Color; @@ -77,22 +78,14 @@ public class DefaultChartTheme extends StandardChartTheme { if (PlatformUI.isWorkbenchRunning()) { IWorkbench workbench = PlatformUI.getWorkbench(); Display display = workbench.getDisplay(); - FontRegistry fontRegistry = workbench.getThemeManager() - .getCurrentTheme().getFontRegistry(); + FontRegistry fontRegistry = workbench.getThemeManager().getCurrentTheme().getFontRegistry(); // JFace doesn't define 'small' font, so derive it from the regular font - Font regularFont = toAwtFont(display, - fontRegistry.getFontData(JFaceResources.DIALOG_FONT)[0], - true); - Font smallFont = regularFont - .deriveFont(Math.max(regularFont.getSize() - 1.0f, 1)); - - setExtraLargeFont(toAwtFont(display, - fontRegistry.getFontData(JFaceResources.HEADER_FONT)[0], - true)); - setLargeFont(toAwtFont(display, - fontRegistry.getFontData(JFaceResources.BANNER_FONT)[0], - true)); + Font regularFont = toAwtFont(display, fontRegistry.getFontData(JFaceResources.DIALOG_FONT)[0], true); + Font smallFont = regularFont.deriveFont(Math.max(regularFont.getSize() - 1.0f, 1)); + + setExtraLargeFont(toAwtFont(display, fontRegistry.getFontData(JFaceResources.HEADER_FONT)[0], true)); + setLargeFont(toAwtFont(display, fontRegistry.getFontData(JFaceResources.BANNER_FONT)[0], true)); setRegularFont(regularFont); setSmallFont(smallFont); } else { @@ -156,7 +149,7 @@ public class DefaultChartTheme extends StandardChartTheme { renderer.setItemLabelInsets(new RectangleInsets(1, 5, 1, 5)); renderer.setDefaultPositiveItemLabelPosition( - new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, ItemLabelClip.FIT)); + new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER, ItemLabelClip.FIT)); } @Override @@ -164,7 +157,7 @@ public class DefaultChartTheme extends StandardChartTheme { super.applyToXYItemRenderer(renderer); if (renderer instanceof XYBarRenderer) { - applyToXYBarRenderer((XYBarRenderer) renderer); + applyToXYBarRenderer((XYBarRenderer)renderer); } } @@ -174,7 +167,7 @@ public class DefaultChartTheme extends StandardChartTheme { renderer.setAutoPopulateSeriesOutlinePaint(true); renderer.setComputeItemLabelContrastColor(true); } - + // Prevent to draw label in small bars final Font font = renderer.getDefaultItemLabelFont(); final FontRenderContext fontRenderContext = new FontRenderContext(font.getTransform(), true, true); @@ -187,24 +180,24 @@ public class DefaultChartTheme extends StandardChartTheme { new ItemLabelPosition(ItemLabelAnchor.INSIDE9, TextAnchor.CENTER_LEFT, ItemLabelClip.CLIP)); } - @Override - protected void applyToXYAnnotation(XYAnnotation annotation) { - super.applyToXYAnnotation(annotation); - if (annotation instanceof XYMeasurementAnnotation) { - applyToXYMeasurementAnnotation((XYMeasurementAnnotation) annotation); - } - } + @Override + protected void applyToXYAnnotation(XYAnnotation annotation) { + super.applyToXYAnnotation(annotation); + if (annotation instanceof XYMeasurementAnnotation) { + applyToXYMeasurementAnnotation((XYMeasurementAnnotation)annotation); + } + } - protected void applyToXYMeasurementAnnotation(XYMeasurementAnnotation annotation) { - annotation.setFont(getRegularFont()); - annotation.setPaint(Color.RED); - } + protected void applyToXYMeasurementAnnotation(XYMeasurementAnnotation annotation) { + annotation.setFont(getRegularFont()); + annotation.setPaint(Color.RED); + } @Override protected void applyToValueAxis(ValueAxis axis) { super.applyToValueAxis(axis); if (axis instanceof SectionAxis) { - applyToSectionsAxis((SectionAxis) axis); + applyToSectionsAxis((SectionAxis)axis); } } @@ -223,45 +216,35 @@ public class DefaultChartTheme extends StandardChartTheme { } } - private static final String Az = "ABCpqr"; + private static final String AZ = "ABCpqr"; - private static final FontRenderContext DEFAULT_FONT_RENDER_CONTEXT = new FontRenderContext( - null, true, true); + private static final FontRenderContext DEFAULT_FONT_RENDER_CONTEXT = new FontRenderContext(null, true, true); /** - * Create an awt font by converting as much information as possible from the - * provided swt FontData. + * Create an awt font by converting as much information as possible from the provided swt FontData. *

- * Generally speaking, given a font size, an swt font will display - * differently on the screen than the corresponding awt one. Because the SWT - * toolkit use native graphical ressources whenever it is possible, this - * fact is platform dependent. To address this issue, it is possible to - * enforce the method to return an awt font with the same height as the swt - * one. + * Generally speaking, given a font size, an swt font will display differently on the screen than the corresponding + * awt one. Because the SWT toolkit use native graphical ressources whenever it is possible, this fact is platform + * dependent. To address this issue, it is possible to enforce the method to return an awt font with the same height + * as the swt one. + *

* - * @param device The swt device being drawn on (display or gc - * device). - * @param fontData The swt font to convert. - * @param ensureSameSize A boolean used to enforce the same size (in pixels) - * between the swt font and the newly created awt - * font. + * @param device The swt device being drawn on (display or gc device). + * @param fontData The swt font to convert. + * @param ensureSameSize A boolean used to enforce the same size (in pixels) between the swt font and the newly + * created awt font. * @return An awt font converted from the provided swt font. * @see org.jfree.experimental.swt.SwtUtils#toAwtFont */ - public static Font toAwtFont(Device device, FontData fontData, - boolean ensureSameSize) { - Font font = new Font(fontData.getName(), fontData.getStyle(), - fontData.getHeight()); + public static Font toAwtFont(Device device, FontData fontData, boolean ensureSameSize) { + Font font = new Font(fontData.getName(), fontData.getStyle(), fontData.getHeight()); if (ensureSameSize) { GC tmpGC = new GC(device); - org.eclipse.swt.graphics.Font tmpFont = new org.eclipse.swt.graphics.Font( - device, fontData); + org.eclipse.swt.graphics.Font tmpFont = new org.eclipse.swt.graphics.Font(device, fontData); tmpGC.setFont(tmpFont); - int swtHeight = tmpGC.textExtent(Az).y; - float awtHeight = (float) font - .getStringBounds(Az, DEFAULT_FONT_RENDER_CONTEXT) - .getHeight(); + int swtHeight = tmpGC.textExtent(AZ).y; + float awtHeight = (float)font.getStringBounds(AZ, DEFAULT_FONT_RENDER_CONTEXT).getHeight(); float scaledSize = (swtHeight * fontData.getHeight()) / awtHeight; font = font.deriveFont(scaledSize); diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/viewers/BackReferenceProvider.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/viewers/BackReferenceProvider.java index 81608da19d63cf8a4f629a153fdbd8baa653cae9..241dea560193023544dec0f98d5738a56ed421ac 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/viewers/BackReferenceProvider.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/viewers/BackReferenceProvider.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.ui.viewers; public interface BackReferenceProvider { diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/viewers/BackReferenceResolver.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/viewers/BackReferenceResolver.java index 7da50fe16fd7369a380fff6c9119ecaad6695b3e..ef6ff57d9fca396e03869bf6efcb6e4bff17a495 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/viewers/BackReferenceResolver.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/viewers/BackReferenceResolver.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.ui.viewers; import org.eclipse.trace4cps.common.jfreechart.data.xy.XYEdgeSeriesCollection; @@ -29,94 +30,74 @@ import org.jfree.data.xy.YIntervalSeriesCollection; public class BackReferenceResolver { public static final BackReferenceResolver DEFAULT = new BackReferenceResolver(); - public BackReferenceProvider resolveBackReferenceProvider( - ChartMouseEvent event) { + public BackReferenceProvider resolveBackReferenceProvider(ChartMouseEvent event) { return resolveBackReferenceProvider(event.getEntity()); } - public BackReferenceProvider resolveBackReferenceProvider( - ChartEntity chartEntity) { + public BackReferenceProvider resolveBackReferenceProvider(ChartEntity chartEntity) { return doResolveBackReferenceProvider(chartEntity); } - public BackReferenceProvider resolveBackReferenceProvider( - Annotation annotation) { + public BackReferenceProvider resolveBackReferenceProvider(Annotation annotation) { return doResolveBackReferenceProvider(annotation); } - public BackReferenceProvider resolveBackReferenceProvider( - XYDataset dataset, int series, int item) { - return doResolveBackReferenceProvider( - resolveDataItem(dataset, series, item)); + public BackReferenceProvider resolveBackReferenceProvider(XYDataset dataset, int series, int item) { + return doResolveBackReferenceProvider(resolveDataItem(dataset, series, item)); } - protected BackReferenceProvider doResolveBackReferenceProvider( - Object o) { + protected BackReferenceProvider doResolveBackReferenceProvider(Object o) { BackReferenceProvider backReferenceProvider = null; if (o instanceof BackReferenceProvider) { - backReferenceProvider = (BackReferenceProvider) o; + backReferenceProvider = (BackReferenceProvider)o; } else if (o instanceof XYItemEntity) { - final XYItemEntity entity = (XYItemEntity) o; - backReferenceProvider = resolveBackReferenceProvider( - entity.getDataset(), entity.getSeriesIndex(), + final XYItemEntity entity = (XYItemEntity)o; + backReferenceProvider = resolveBackReferenceProvider(entity.getDataset(), entity.getSeriesIndex(), entity.getItem()); } else if (o instanceof PieSectionEntity) { - final PieSectionEntity entity = (PieSectionEntity) o; - backReferenceProvider = doResolveBackReferenceProvider( - entity.getSectionKey()); + final PieSectionEntity entity = (PieSectionEntity)o; + backReferenceProvider = doResolveBackReferenceProvider(entity.getSectionKey()); } else if (o instanceof CategoryItemEntity) { - final CategoryItemEntity entity = (CategoryItemEntity) o; - backReferenceProvider = doResolveBackReferenceProvider( - entity.getColumnKey()); + final CategoryItemEntity entity = (CategoryItemEntity)o; + backReferenceProvider = doResolveBackReferenceProvider(entity.getColumnKey()); if (backReferenceProvider == null) { - backReferenceProvider = doResolveBackReferenceProvider( - entity.getRowKey()); + backReferenceProvider = doResolveBackReferenceProvider(entity.getRowKey()); } } return backReferenceProvider; } protected Object resolveDataItem(XYDataset dataset, int series, int item) { - if (series >= dataset.getSeriesCount() - || item >= dataset.getItemCount(series)) { + if (series >= dataset.getSeriesCount() || item >= dataset.getItemCount(series)) { // Avoiding java.lang.IndexOutOfBoundsException return null; } if (dataset instanceof XYIntervalSeriesCollection) { - return ((XYIntervalSeriesCollection) dataset).getSeries(series) - .getDataItem(item); + return ((XYIntervalSeriesCollection)dataset).getSeries(series).getDataItem(item); } if (dataset instanceof XYSeriesCollection) { - return ((XYSeriesCollection) dataset).getSeries(series) - .getDataItem(item); + return ((XYSeriesCollection)dataset).getSeries(series).getDataItem(item); } if (dataset instanceof XYEdgeSeriesCollection) { - return ((XYEdgeSeriesCollection) dataset).getSeries(series) - .getDataItem(item); + return ((XYEdgeSeriesCollection)dataset).getSeries(series).getDataItem(item); } if (dataset instanceof XIntervalSeriesCollection) { - return ((XIntervalSeriesCollection) dataset).getSeries(series) - .getDataItem(item); + return ((XIntervalSeriesCollection)dataset).getSeries(series).getDataItem(item); } if (dataset instanceof YIntervalSeriesCollection) { - return ((YIntervalSeriesCollection) dataset).getSeries(series) - .getDataItem(item); + return ((YIntervalSeriesCollection)dataset).getSeries(series).getDataItem(item); } if (dataset instanceof OHLCSeriesCollection) { - return ((OHLCSeriesCollection) dataset).getSeries(series) - .getDataItem(item); + return ((OHLCSeriesCollection)dataset).getSeries(series).getDataItem(item); } if (dataset instanceof TimePeriodValuesCollection) { - return ((TimePeriodValuesCollection) dataset).getSeries(series) - .getDataItem(item); + return ((TimePeriodValuesCollection)dataset).getSeries(series).getDataItem(item); } if (dataset instanceof TimeSeriesCollection) { - return ((TimeSeriesCollection) dataset).getSeries(series) - .getDataItem(item); + return ((TimeSeriesCollection)dataset).getSeries(series).getDataItem(item); } if (dataset instanceof VectorSeriesCollection) { - return ((VectorSeriesCollection) dataset).getSeries(series) - .getDataItem(item); + return ((VectorSeriesCollection)dataset).getSeries(series).getDataItem(item); } return null; } diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/viewers/BackReferenceTextGenerator.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/viewers/BackReferenceTextGenerator.java index 87bc98c7f87584673f82f19ae357d90137705518..56b21f9d4f6b06f66f5e2dabee7af43375f01c06 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/viewers/BackReferenceTextGenerator.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/viewers/BackReferenceTextGenerator.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.ui.viewers; import org.eclipse.jface.viewers.ILabelProvider; @@ -15,9 +16,9 @@ import org.jfree.chart.labels.XYItemLabelGenerator; import org.jfree.chart.labels.XYToolTipGenerator; import org.jfree.data.xy.XYDataset; -public class BackReferenceTextGenerator - implements XYItemLabelGenerator, XYToolTipGenerator { +public class BackReferenceTextGenerator implements XYItemLabelGenerator, XYToolTipGenerator { private final ILabelProvider labelProvider; + private final BackReferenceResolver backReferenceResolver; public BackReferenceTextGenerator() { @@ -28,8 +29,7 @@ public class BackReferenceTextGenerator this(labelProvider, BackReferenceResolver.DEFAULT); } - public BackReferenceTextGenerator(ILabelProvider labelProvider, - BackReferenceResolver backReferenceResolver) { + public BackReferenceTextGenerator(ILabelProvider labelProvider, BackReferenceResolver backReferenceResolver) { this.labelProvider = labelProvider; this.backReferenceResolver = backReferenceResolver; } diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/viewers/ChartPanelContentViewer.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/viewers/ChartPanelContentViewer.java index bccee966052e8deb9dc3dfb4c340532ed8a54cba..88433389842fb55f5ad59afb307bc704b01a1317 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/viewers/ChartPanelContentViewer.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/viewers/ChartPanelContentViewer.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.ui.viewers; import org.eclipse.jface.viewers.ContentViewer; @@ -23,10 +24,10 @@ import org.jfree.chart.plot.Plot; import org.jfree.chart.util.Args; public abstract class ChartPanelContentViewer extends ContentViewer { - private final Composite parentComposite; private ISelection selection = StructuredSelection.EMPTY; + private boolean preserveSelection = false; private ChartPanelControlTuple controlTuple = null; @@ -56,29 +57,23 @@ public abstract class ChartPanelContentViewer extends ContentViewer { private ChartPanelControlTuple getControlTuple() { if (null == controlTuple) { - controlTuple = createControl(parentComposite, - SWT.H_SCROLL | SWT.V_SCROLL, SelectionType.Multi); + controlTuple = createControl(parentComposite, SWT.H_SCROLL | SWT.V_SCROLL, SelectionType.Multi); } return controlTuple; } /** * Creates a {@link ChartPanelComposite} for this viewer.
- * NOTE: This method should not call any other method of - * {@link ChartPanelContentViewer}, except for its super method. - * - * @param parent the composite to add the {@link ChartPanelComposite} - * to - * @param style the style to apply to the - * {@link ChartPanelComposite} - * @param selectionType the selection type to apply to this - * {@link ChartPanelContentViewer} - * @return a tuple containing both the {@link ChartPanelComposite} and the - * {@link Control} it is added to which may be the - * {@link ChartPanelComposite} itself. + * NOTE: This method should not call any other method of {@link ChartPanelContentViewer}, except for its + * super method. + * + * @param parent the composite to add the {@link ChartPanelComposite} to + * @param style the style to apply to the {@link ChartPanelComposite} + * @param selectionType the selection type to apply to this {@link ChartPanelContentViewer} + * @return a tuple containing both the {@link ChartPanelComposite} and the {@link Control} it is added to which may + * be the {@link ChartPanelComposite} itself. */ - protected ChartPanelControlTuple createControl(Composite parent, int style, - SelectionType selectionType) { + protected ChartPanelControlTuple createControl(Composite parent, int style, SelectionType selectionType) { ChartPanelComposite composite = new ChartPanelComposite(parent, style); return new ChartPanelControlTuple(composite, composite, selectionType); } @@ -146,32 +141,31 @@ public abstract class ChartPanelContentViewer extends ContentViewer { protected final class ChartPanelControlTuple { private final Control control; + private final ChartPanelComposite chartPanelComposite; + private final ChartPanelSelectionHandler chartPanelSelectionHandler; /** - * @param control the SWT control which displays this - * viewer's content - * @param chartPanelComposite the SWT composite which displays this - * viewer's {@link JFreeChart} - * @param selectionType the selection type to use for this viewer + * @param control the SWT control which displays this viewer's content + * @param chartPanelComposite the SWT composite which displays this viewer's {@link JFreeChart} + * @param selectionType the selection type to use for this viewer */ - public ChartPanelControlTuple(Control control, - ChartPanelComposite chartPanelComposite, - SelectionType selectionType) { + public ChartPanelControlTuple(Control control, ChartPanelComposite chartPanelComposite, + SelectionType selectionType) + { Args.nullNotPermitted(control, "control"); Args.nullNotPermitted(chartPanelComposite, "chartPanelComposite"); Args.nullNotPermitted(selectionType, "selectionType"); this.control = control; this.chartPanelComposite = chartPanelComposite; - this.chartPanelSelectionHandler = new ChartPanelSelectionHandler( - chartPanelComposite.getChartPanel(), + this.chartPanelSelectionHandler = new ChartPanelSelectionHandler(chartPanelComposite.getChartPanel(), ChartPanelContentViewer.this, selectionType); } /** * Returns the primary control associated with this viewer. - * + * * @return the SWT control which displays this viewer's content * @see ContentViewer#getControl() */ @@ -181,9 +175,8 @@ public abstract class ChartPanelContentViewer extends ContentViewer { /** * Returns the chart-panel composite associated with this viewer. - * - * @return the SWT composite which displays this viewer's - * {@link JFreeChart} + * + * @return the SWT composite which displays this viewer's {@link JFreeChart} */ public ChartPanelComposite getChartPanelComposite() { return chartPanelComposite; @@ -191,11 +184,11 @@ public abstract class ChartPanelContentViewer extends ContentViewer { /** * Returns the selection handler for this viewer - * + * * @return the selection handler for this viewer */ public ChartPanelSelectionHandler getChartPanelSelectionHandler() { return chartPanelSelectionHandler; } } -} \ No newline at end of file +} diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/viewers/ChartPanelSelectionHandler.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/viewers/ChartPanelSelectionHandler.java index 6e6f60996067cfb26c26650e44402f3d5f4e1638..0a0209611951debaaf281b8a2a0f1cd1d1dd3225 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/viewers/ChartPanelSelectionHandler.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/viewers/ChartPanelSelectionHandler.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.ui.viewers; import java.awt.BasicStroke; @@ -59,24 +60,28 @@ public class ChartPanelSelectionHandler { } private final MouseSelectionListener mouseSelectionListener = new MouseSelectionListener(); + private final SelectionOverlay selectionOverlay = new SelectionOverlay(); private final ChartPanel chartPanel; + private final ISelectionProvider selectionProvider; private BackReferenceResolver backReferenceResolver = BackReferenceResolver.DEFAULT; + private double zoomToSelectionMargin = 0; + private SelectionType selectionType; - public static ChartPanelSelectionHandler connectSelection( - ChartPanel chartPanel, ISelectionProvider selectionProvider, - SelectionType selectionType) { - return new ChartPanelSelectionHandler(chartPanel, selectionProvider, - selectionType); + public static ChartPanelSelectionHandler connectSelection(ChartPanel chartPanel, + ISelectionProvider selectionProvider, SelectionType selectionType) + { + return new ChartPanelSelectionHandler(chartPanel, selectionProvider, selectionType); } - public ChartPanelSelectionHandler(ChartPanel chartPanel, - ISelectionProvider selectionProvider, SelectionType selectionType) { + public ChartPanelSelectionHandler(ChartPanel chartPanel, ISelectionProvider selectionProvider, + SelectionType selectionType) + { Args.nullNotPermitted(chartPanel, "chartPanel"); Args.nullNotPermitted(selectionProvider, "selectionProvider"); this.chartPanel = chartPanel; @@ -109,17 +114,16 @@ public class ChartPanelSelectionHandler { this.selectionType = selectionType; switch (selectionType) { - case Single: - case Multi: - this.chartPanel.addChartMouseListener(mouseSelectionListener); - // No break, continue next case - case ReadOnly: - this.selectionProvider - .addSelectionChangedListener(selectionOverlay); - this.chartPanel.addOverlay(selectionOverlay); - break; - case None: - // Do nothing, already deregistered + case Single: + case Multi: + this.chartPanel.addChartMouseListener(mouseSelectionListener); + // No break, continue next case + case ReadOnly: + this.selectionProvider.addSelectionChangedListener(selectionOverlay); + this.chartPanel.addOverlay(selectionOverlay); + break; + case None: + // Do nothing, already deregistered } } @@ -151,8 +155,7 @@ public class ChartPanelSelectionHandler { return backReferenceResolver; } - public void setBackReferenceResolver( - BackReferenceResolver backReferenceResolver) { + public void setBackReferenceResolver(BackReferenceResolver backReferenceResolver) { this.backReferenceResolver = backReferenceResolver; } @@ -170,7 +173,7 @@ public class ChartPanelSelectionHandler { double minY = Double.POSITIVE_INFINITY; double maxX = Double.NEGATIVE_INFINITY; double maxY = Double.NEGATIVE_INFINITY; - for (Rectangle2D bounds : selectionBounds.values()) { + for (Rectangle2D bounds: selectionBounds.values()) { minX = Math.min(minX, bounds.getMinX()); minY = Math.min(minY, bounds.getMinY()); maxX = Math.max(maxX, bounds.getMaxX()); @@ -186,20 +189,19 @@ public class ChartPanelSelectionHandler { maxY += marginY; // Keep zoom if specified - Rectangle2D dataArea = chartPanel.getChartRenderingInfo().getPlotInfo() - .getDataArea(); + Rectangle2D dataArea = chartPanel.getChartRenderingInfo().getPlotInfo().getDataArea(); switch (zoomType) { - case X: - minY = dataArea.getMinY(); - maxY = dataArea.getMaxY(); - break; - case Y: - minX = dataArea.getMinX(); - maxX = dataArea.getMaxX(); - break; - default: - // Nothing to do - break; + case X: + minY = dataArea.getMinY(); + maxY = dataArea.getMaxY(); + break; + case Y: + minX = dataArea.getMinX(); + maxX = dataArea.getMaxX(); + break; + default: + // Nothing to do + break; } // Zooming with a width or height of 0 will be ignored, hence max with @@ -214,41 +216,33 @@ public class ChartPanelSelectionHandler { protected Map getSelectionBounds() { ISelection selection = selectionProvider.getSelection(); Plot plot = chartPanel.getChart().getPlot(); - if (!(plot instanceof XYPlot) - || !(selection instanceof StructuredSelection) - || selection.isEmpty()) + if (!(plot instanceof XYPlot) || !(selection instanceof StructuredSelection) || selection.isEmpty()) return Collections.emptyMap(); - List selectionItems = ((StructuredSelection) selection).toList(); - XYPlot xyPlot = (XYPlot) plot; + List selectionItems = ((StructuredSelection)selection).toList(); + XYPlot xyPlot = (XYPlot)plot; - Rectangle2D dataArea = chartPanel.getChartRenderingInfo().getPlotInfo() - .getDataArea(); - Map selectionBounds = new HashMap<>( - selectionItems.size()); + Rectangle2D dataArea = chartPanel.getChartRenderingInfo().getPlotInfo().getDataArea(); + Map selectionBounds = new HashMap<>(selectionItems.size()); for (int d = 0; d < xyPlot.getDatasetCount(); d++) { XYDataset ds = xyPlot.getDataset(d); if (!(ds instanceof IntervalXYDataset)) continue; - IntervalXYDataset dataset = (IntervalXYDataset) ds; + IntervalXYDataset dataset = (IntervalXYDataset)ds; ValueAxis domainAxis = xyPlot.getDomainAxisForDataset(d); ValueAxis rangeAxis = xyPlot.getRangeAxisForDataset(d); XYItemRenderer renderer = xyPlot.getRendererForDataset(ds); if (null != renderer) { - for (XYAnnotation xyAnnotation : (List) renderer - .getAnnotations()) { + for (XYAnnotation xyAnnotation: (List)renderer.getAnnotations()) { Object selectionItem = getSelectionItem(xyAnnotation); - if (null != selectionItem - && selectionItems.contains(selectionItem) - && xyAnnotation instanceof XYAnnotationBoundsInfo) { - final Range xRange = ((XYAnnotationBoundsInfo) xyAnnotation) - .getXRange(); - final Range yRange = ((XYAnnotationBoundsInfo) xyAnnotation) - .getYRange(); - Rectangle2D j2DBounds = valueToJava2D( - xRange.getLowerBound(), yRange.getLowerBound(), - xRange.getUpperBound(), yRange.getUpperBound(), - xyPlot, dataArea, domainAxis, rangeAxis); + if (null != selectionItem && selectionItems.contains(selectionItem) + && xyAnnotation instanceof XYAnnotationBoundsInfo) + { + final Range xRange = ((XYAnnotationBoundsInfo)xyAnnotation).getXRange(); + final Range yRange = ((XYAnnotationBoundsInfo)xyAnnotation).getYRange(); + Rectangle2D j2DBounds = valueToJava2D(xRange.getLowerBound(), yRange.getLowerBound(), + xRange.getUpperBound(), yRange.getUpperBound(), xyPlot, dataArea, domainAxis, + rangeAxis); addBounds(selectionBounds, selectionItem, j2DBounds); } } @@ -258,14 +252,12 @@ public class ChartPanelSelectionHandler { final int itemCount = dataset.getItemCount(s); for (int i = 0; i < itemCount; i++) { Object selectionItem = getSelectionItem(dataset, s, i); - if (null != selectionItem - && selectionItems.contains(selectionItem)) { + if (null != selectionItem && selectionItems.contains(selectionItem)) { double xStart = dataset.getStartXValue(s, i); double yStart = dataset.getStartYValue(s, i); double xEnd = dataset.getEndXValue(s, i); double yEnd = dataset.getEndYValue(s, i); - Rectangle2D j2DBounds = valueToJava2D(xStart, yStart, - xEnd, yEnd, xyPlot, dataArea, domainAxis, + Rectangle2D j2DBounds = valueToJava2D(xStart, yStart, xEnd, yEnd, xyPlot, dataArea, domainAxis, rangeAxis); addBounds(selectionBounds, selectionItem, j2DBounds); } @@ -273,19 +265,16 @@ public class ChartPanelSelectionHandler { } } - for (XYAnnotation xyAnnotation : (List) xyPlot - .getAnnotations()) { + for (XYAnnotation xyAnnotation: (List)xyPlot.getAnnotations()) { Object selectionItem = getSelectionItem(xyAnnotation); if (null != selectionItem && selectionItems.contains(selectionItem) - && xyAnnotation instanceof XYAnnotationBoundsInfo) { - final Range xRange = ((XYAnnotationBoundsInfo) xyAnnotation) - .getXRange(); - final Range yRange = ((XYAnnotationBoundsInfo) xyAnnotation) - .getYRange(); - Rectangle2D j2DBounds = valueToJava2D(xRange.getLowerBound(), - yRange.getLowerBound(), xRange.getUpperBound(), - yRange.getUpperBound(), xyPlot, dataArea, - xyPlot.getDomainAxis(), xyPlot.getRangeAxis()); + && xyAnnotation instanceof XYAnnotationBoundsInfo) + { + final Range xRange = ((XYAnnotationBoundsInfo)xyAnnotation).getXRange(); + final Range yRange = ((XYAnnotationBoundsInfo)xyAnnotation).getYRange(); + Rectangle2D j2DBounds = valueToJava2D(xRange.getLowerBound(), yRange.getLowerBound(), + xRange.getUpperBound(), yRange.getUpperBound(), xyPlot, dataArea, xyPlot.getDomainAxis(), + xyPlot.getRangeAxis()); addBounds(selectionBounds, selectionItem, j2DBounds); } } @@ -293,60 +282,48 @@ public class ChartPanelSelectionHandler { return selectionBounds; } - protected Rectangle2D valueToJava2D(double x1, double y1, double x2, - double y2, XYPlot xyPlot, Rectangle2D dataArea, - ValueAxis domainAxis, ValueAxis rangeAxis) { - RectangleEdge domainAxisEdge = xyPlot - .getDomainAxisEdge(xyPlot.getDomainAxisIndex(domainAxis)); - RectangleEdge rangeAxisEdge = xyPlot - .getRangeAxisEdge(xyPlot.getRangeAxisIndex(rangeAxis)); + protected Rectangle2D valueToJava2D(double x1, double y1, double x2, double y2, XYPlot xyPlot, Rectangle2D dataArea, + ValueAxis domainAxis, ValueAxis rangeAxis) + { + RectangleEdge domainAxisEdge = xyPlot.getDomainAxisEdge(xyPlot.getDomainAxisIndex(domainAxis)); + RectangleEdge rangeAxisEdge = xyPlot.getRangeAxisEdge(xyPlot.getRangeAxisIndex(rangeAxis)); - boolean isVerticalOrientation = xyPlot - .getOrientation() == PlotOrientation.VERTICAL; + boolean isVerticalOrientation = xyPlot.getOrientation() == PlotOrientation.VERTICAL; ValueAxis xAxis = isVerticalOrientation ? domainAxis : rangeAxis; - RectangleEdge xAxisEdge = isVerticalOrientation ? domainAxisEdge - : rangeAxisEdge; + RectangleEdge xAxisEdge = isVerticalOrientation ? domainAxisEdge : rangeAxisEdge; ValueAxis yAxis = isVerticalOrientation ? rangeAxis : domainAxis; - RectangleEdge yAxisEdge = isVerticalOrientation ? rangeAxisEdge - : domainAxisEdge; + RectangleEdge yAxisEdge = isVerticalOrientation ? rangeAxisEdge : domainAxisEdge; double j2DX1 = xAxis.valueToJava2D(x1, dataArea, xAxisEdge); double j2DY1 = yAxis.valueToJava2D(y1, dataArea, yAxisEdge); double j2DX2 = xAxis.valueToJava2D(x2, dataArea, xAxisEdge); double j2DY2 = yAxis.valueToJava2D(y2, dataArea, yAxisEdge); - return new Rectangle2D.Double(Math.min(j2DX1, j2DX2), - Math.min(j2DY1, j2DY2), Math.abs(j2DX2 - j2DX1), + return new Rectangle2D.Double(Math.min(j2DX1, j2DX2), Math.min(j2DY1, j2DY2), Math.abs(j2DX2 - j2DX1), Math.abs(j2DY2 - j2DY1)); } /** * Selection items might be represented as multiple items on the screen */ - private void addBounds(Map map, Object o, - Rectangle2D bounds) { + private void addBounds(Map map, Object o, Rectangle2D bounds) { map.compute(o, (k, v) -> null == v ? bounds : bounds.createUnion(v)); } protected Object getSelectionItem(ChartEntity chartEntity) { BackReferenceProvider backReferenceProvider = backReferenceResolver .resolveBackReferenceProvider(chartEntity); - return null == backReferenceProvider ? null - : backReferenceProvider.getBackReference(); + return null == backReferenceProvider ? null : backReferenceProvider.getBackReference(); } - protected Object getSelectionItem(XYDataset dataset, int seriesIndex, - int item) { - BackReferenceProvider backReferenceProvider = backReferenceResolver - .resolveBackReferenceProvider(dataset, seriesIndex, item); - return null == backReferenceProvider ? null - : backReferenceProvider.getBackReference(); + protected Object getSelectionItem(XYDataset dataset, int seriesIndex, int item) { + BackReferenceProvider backReferenceProvider = backReferenceResolver.resolveBackReferenceProvider(dataset, + seriesIndex, item); + return null == backReferenceProvider ? null : backReferenceProvider.getBackReference(); } protected Object getSelectionItem(XYAnnotation annotation) { - BackReferenceProvider backReferenceProvider = backReferenceResolver - .resolveBackReferenceProvider(annotation); - return null == backReferenceProvider ? null - : backReferenceProvider.getBackReference(); + BackReferenceProvider backReferenceProvider = backReferenceResolver.resolveBackReferenceProvider(annotation); + return null == backReferenceProvider ? null : backReferenceProvider.getBackReference(); } private class MouseSelectionListener implements ChartMouseListener { @@ -357,9 +334,9 @@ public class ChartPanelSelectionHandler { @Override public void chartMouseClicked(ChartMouseEvent event) { - if (event.getTrigger().isAltDown() - || event.getTrigger().isAltGraphDown() - || event.getTrigger().isMetaDown()) { + if (event.getTrigger().isAltDown() || event.getTrigger().isAltGraphDown() + || event.getTrigger().isMetaDown()) + { return; } Object selectionItem = getSelectionItem(event.getEntity()); @@ -368,13 +345,12 @@ public class ChartPanelSelectionHandler { return; } final StructuredSelection selection; - if (selectionType == SelectionType.Multi - && event.getTrigger().isControlDown() - && !selectionProvider.getSelection().isEmpty()) { + if (selectionType == SelectionType.Multi && event.getTrigger().isControlDown() + && !selectionProvider.getSelection().isEmpty()) + { @SuppressWarnings("unchecked") ArrayList newSelection = new ArrayList( - ((StructuredSelection) selectionProvider.getSelection()) - .toList()); + ((StructuredSelection)selectionProvider.getSelection()).toList()); if (!newSelection.remove(selectionItem)) { newSelection.add(selectionItem); } @@ -390,8 +366,7 @@ public class ChartPanelSelectionHandler { } } - private class SelectionOverlay extends AbstractOverlay - implements Overlay, ISelectionChangedListener { + private class SelectionOverlay extends AbstractOverlay implements Overlay, ISelectionChangedListener { /** The border paint for the selected bar. */ private Paint selectionPaint = new Color(255, 255, 0, 200); @@ -409,36 +384,29 @@ public class ChartPanelSelectionHandler { if (selection == null || selection.isEmpty()) return; - Graphics2D g = (Graphics2D) g2.create(); + Graphics2D g = (Graphics2D)g2.create(); g.clip(chartPanel.getScreenDataArea()); g.setStroke(selectionStroke); g.setPaint(selectionPaint); - for (ChartEntity chartEntity : getSelectedChartEntities( - selection)) { + for (ChartEntity chartEntity: getSelectedChartEntities(selection)) { AffineTransform transform = new AffineTransform(); transform.scale(chartPanel.getScaleX(), chartPanel.getScaleY()); - Shape selectionShape = transform - .createTransformedShape(chartEntity.getArea()); + Shape selectionShape = transform.createTransformedShape(chartEntity.getArea()); g.draw(selectionStroke.createStrokedShape(selectionShape)); } } - private Collection getSelectedChartEntities( - ISelection selection) { - if (selection.isEmpty() - || !(selection instanceof StructuredSelection)) + private Collection getSelectedChartEntities(ISelection selection) { + if (selection.isEmpty() || !(selection instanceof StructuredSelection)) return Collections.emptyList(); - List selectionItems = ((StructuredSelection) selection).toList(); - Collection result = new ArrayList<>( - selectionItems.size()); - for (Object chartEntity : chartPanel.getChartRenderingInfo() - .getEntityCollection().getEntities()) { - Object selectionItem = getSelectionItem( - (ChartEntity) chartEntity); + List selectionItems = ((StructuredSelection)selection).toList(); + Collection result = new ArrayList<>(selectionItems.size()); + for (Object chartEntity: chartPanel.getChartRenderingInfo().getEntityCollection().getEntities()) { + Object selectionItem = getSelectionItem((ChartEntity)chartEntity); if (selectionItems.contains(selectionItem)) { - result.add((ChartEntity) chartEntity); + result.add((ChartEntity)chartEntity); } } return result; diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/viewers/SelectionProvider.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/viewers/SelectionProvider.java index 5ed793348e9083da0d7a73eb59720c645eabeeb1..139f713b6e75613c748598a499ecda926e1a62f3 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/viewers/SelectionProvider.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/viewers/SelectionProvider.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.ui.viewers; import org.eclipse.core.runtime.ListenerList; @@ -24,7 +25,9 @@ import org.jfree.chart.util.Args; */ public class SelectionProvider implements ISelectionProvider { private final ListenerList selectionChangedListeners = new ListenerList<>(); + private final ISelection emptySelection; + private ISelection selection; public SelectionProvider() { @@ -32,19 +35,16 @@ public class SelectionProvider implements ISelectionProvider { } /** - * Use this constructor if your selection provider requires another type - * than {@link IStructuredSelection} for its empty selection. - * - * @throws IllegalArgumentException if {@link ISelection#isEmpty() - * emptySelection.isEmpty()} returns - * {@code false}. - * @param emptySelection + * Use this constructor if your selection provider requires another type than {@link IStructuredSelection} for its + * empty selection. + * + * @param emptySelection An {@link ISelection#isEmpty() empty} selection that is used to {@link #clearSelection()}. + * @throws IllegalArgumentException if {@link ISelection#isEmpty() emptySelection.isEmpty()} returns {@code false}. */ public SelectionProvider(ISelection emptySelection) { Args.nullNotPermitted(emptySelection, "emptySelection"); if (!emptySelection.isEmpty()) { - throw new IllegalArgumentException( - "emptySelection should return true on isEmpty()"); + throw new IllegalArgumentException("emptySelection should return true on isEmpty()"); } this.emptySelection = emptySelection; this.selection = emptySelection; @@ -66,28 +66,25 @@ public class SelectionProvider implements ISelectionProvider { } @Override - public void addSelectionChangedListener( - ISelectionChangedListener listener) { + public void addSelectionChangedListener(ISelectionChangedListener listener) { selectionChangedListeners.add(listener); } @Override - public void removeSelectionChangedListener( - ISelectionChangedListener listener) { + public void removeSelectionChangedListener(ISelectionChangedListener listener) { selectionChangedListeners.remove(listener); } /** - * Notifies any selection changed listeners that the viewer's selection has - * changed. Only listeners registered at the time this method is called are - * notified. + * Notifies any selection changed listeners that the viewer's selection has changed. Only listeners registered at + * the time this method is called are notified. * * @param event a selection changed event * * @see ISelectionChangedListener#selectionChanged */ protected void fireSelectionChanged(final SelectionChangedEvent event) { - for (ISelectionChangedListener l : selectionChangedListeners) { + for (ISelectionChangedListener l: selectionChangedListeners) { SafeRunnable.run(new SafeRunnable() { @Override public void run() { diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/widgets/ChartPanelComposite.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/widgets/ChartPanelComposite.java index 8c9f6dcd8c24dc8cd9ac4606260f12a10c461d08..41591361601c46ff63b71de7c425bc21318b2cab 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/widgets/ChartPanelComposite.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/src/org/eclipse/trace4cps/common/jfreechart/ui/widgets/ChartPanelComposite.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.ui.widgets; import static org.eclipse.core.runtime.IStatus.ERROR; @@ -44,29 +45,27 @@ import org.jfree.chart.util.Args; public class ChartPanelComposite extends Composite { private final Frame baseFrame; + private final ChartPanel chartPanel; + private final ChartPanelScrollbarHandler scrollbarHandler; public ChartPanelComposite(Composite parent, int style) { this(ChartPanelFactory.createChartPanel(null), parent, style); } - public ChartPanelComposite(ChartPanel chartPanel, Composite parent, - int style) { + public ChartPanelComposite(ChartPanel chartPanel, Composite parent, int style) { super(parent, SWT.EMBEDDED | style); Args.nullNotPermitted(chartPanel, "chartPanel"); this.baseFrame = SWT_AWT.new_Frame(this); this.chartPanel = chartPanel; this.scrollbarHandler = new ChartPanelScrollbarHandler(this); - final Color background = toAwtColor( - getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); + final Color background = toAwtColor(getDisplay().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); try { invokeAndWait(() -> createAWTComponent(baseFrame, background)); } catch (InvocationTargetException | InterruptedException e) { - IStatus status = new Status(ERROR, PLUGIN_ID, - "Failed to create AWT component: " - + e.getLocalizedMessage(), + IStatus status = new Status(ERROR, PLUGIN_ID, "Failed to create AWT component: " + e.getLocalizedMessage(), e); StatusManager.getManager().handle(status); } @@ -130,8 +129,7 @@ public class ChartPanelComposite extends Composite { try { invokeAndWait(() -> chartPanel.setChart(chart)); } catch (InvocationTargetException | InterruptedException e) { - IStatus status = new Status(ERROR, PLUGIN_ID, - "Failed to set chart: " + e.getLocalizedMessage(), e); + IStatus status = new Status(ERROR, PLUGIN_ID, "Failed to set chart: " + e.getLocalizedMessage(), e); StatusManager.getManager().handle(status); } } @@ -151,53 +149,46 @@ public class ChartPanelComposite extends Composite { /** *

- * Workaround for Eclipse bug 377104 where frame activation is not being - * properly propagated into SWT on Java 7. + * Workaround for Eclipse bug 377104 where frame activation is not being properly propagated into SWT on Java 7. *

* - * + * * Eclipse Bug 377104 - * - * @param frame Swing frame + * + * @param frame Swing frame * @param embedded Composite containing embedded swing components */ - private static final void workaround377104(final Frame frame, - final Composite embedded) { + private static final void workaround377104(final Frame frame, final Composite embedded) { if (System.getProperty("java.version").startsWith("1.7") - || System.getProperty("java.version").startsWith("1.8")) { + || System.getProperty("java.version").startsWith("1.8")) + { frame.addWindowListener(new java.awt.event.WindowAdapter() { @Override public void windowActivated(java.awt.event.WindowEvent e) { embedded.getDisplay().asyncExec(() -> { - if (Display.getCurrent() - .getFocusControl() == embedded) { + if (Display.getCurrent().getFocusControl() == embedded) { Stack stack = new Stack(); Control starter = embedded; Shell shell = embedded.getShell(); - while (starter != null - && !(starter instanceof Shell)) { + while (starter != null && !(starter instanceof Shell)) { stack.push(starter.getParent()); starter = starter.getParent(); } Method m = null; try { - m = shell.getClass().getDeclaredMethod( - "setActiveControl", Control.class); + m = shell.getClass().getDeclaredMethod("setActiveControl", Control.class); m.setAccessible(true); while (!stack.isEmpty()) { m.invoke(shell, stack.pop()); } - } catch (NoSuchMethodException | SecurityException - | IllegalAccessException - | IllegalArgumentException - | InvocationTargetException e1) { + } catch (NoSuchMethodException | SecurityException | IllegalAccessException + | IllegalArgumentException | InvocationTargetException e1) + { String msg = "Embedded part was not able to set active control on Shell. " + "This will result in other workbench parts not getting activated."; - IStatus status = new Status(ERROR, PLUGIN_ID, - msg, e1); - JFreeChartUIPlugin.getDefault().getLog() - .log(status); + IStatus status = new Status(ERROR, PLUGIN_ID, msg, e1); + JFreeChartUIPlugin.getDefault().getLog().log(status); } finally { if (m != null) { m.setAccessible(false); @@ -209,48 +200,40 @@ public class ChartPanelComposite extends Composite { }); } } - + private static java.awt.Color toAwtColor(org.eclipse.swt.graphics.Color color) { return new java.awt.Color(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha()); } /** - * Causes the {@link Runnable#run() run method of runnable} to be called in - * the {@link #isDispatchThread dispatch thread} of - * {@link Toolkit#getSystemEventQueue the system EventQueue}. This will - * happen after all pending events are processed. The call blocks until this - * has happened. When this method is called from the - * {@link #isDispatchThread event dispatcher thread}, it simply invokes the - * {@link Runnable#run() run method of runnable} This will happen after all - * pending events are processed. - * - * @param runnable the Runnable whose run method - * should be executed synchronously in the - * {@link #isDispatchThread event dispatch thread} of - * {@link Toolkit#getSystemEventQueue the system EventQueue} - * @exception InterruptedException if any thread has interrupted this - * thread - * @exception InvocationTargetException if an throwable is thrown when - * running runnable + * Causes the {@link Runnable#run() run method of runnable} to be called in the {@link #isDispatchThread dispatch + * thread} of {@link Toolkit#getSystemEventQueue the system EventQueue}. This will happen after all pending events + * are processed. The call blocks until this has happened. When this method is called from the + * {@link #isDispatchThread event dispatcher thread}, it simply invokes the {@link Runnable#run() run method of + * runnable} This will happen after all pending events are processed. + * + * @param runnable the Runnable whose run method should be executed synchronously in the + * {@link #isDispatchThread event dispatch thread} of {@link Toolkit#getSystemEventQueue the system EventQueue} + * @exception InterruptedException if any thread has interrupted this thread + * @exception InvocationTargetException if an throwable is thrown when running runnable * @see EventQueue#invokeAndWait(Runnable) */ - private static void invokeAndWait(Runnable runnable) - throws InvocationTargetException, InterruptedException { - if (EventQueue.isDispatchThread()) { - try { - runnable.run(); - } catch (Exception e) { - throw new InvocationTargetException(e); - } - } else { - EventQueue.invokeAndWait(runnable); - } + private static void invokeAndWait(Runnable runnable) throws InvocationTargetException, InterruptedException { + if (EventQueue.isDispatchThread()) { + try { + runnable.run(); + } catch (Exception e) { + throw new InvocationTargetException(e); + } + } else { + EventQueue.invokeAndWait(runnable); + } } private class SWTMenuActivator extends MouseAdapter { + @Override public void mouseReleased(MouseEvent e) { - if (e.isPopupTrigger() && !e.isConsumed() && !isDisposed() - && !getDisplay().isDisposed()) { + if (e.isPopupTrigger() && !e.isConsumed() && !isDisposed() && !getDisplay().isDisposed()) { getDisplay().syncExec(() -> { final Menu menu = getMenu(); if (null != menu) { diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart/.checkstyle b/jfreechart/org.eclipse.trace4cps.common.jfreechart/.checkstyle new file mode 100644 index 0000000000000000000000000000000000000000..b01fc54c7363d48a5fce265944ff35f3519d22f6 --- /dev/null +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart/.checkstyle @@ -0,0 +1,7 @@ + + + + + + + diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart/.project b/jfreechart/org.eclipse.trace4cps.common.jfreechart/.project index ba32884a15610446da6c03cac2b28330fc08322e..d945523851aecea009d7cd5ccbc08c499ceca77f 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart/.project +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart/.project @@ -20,9 +20,15 @@ + + net.sf.eclipsecs.core.CheckstyleBuilder + + + org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + net.sf.eclipsecs.core.CheckstyleNature diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/ZoomAndPanKeyboardHandler.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/ZoomAndPanKeyboardHandler.java index 47e8b3954d5e8bfe8d52df81a91fb12d25a83a73..ecf4964f302f39b4893808990b44f2edc5998bd8 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/ZoomAndPanKeyboardHandler.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/ZoomAndPanKeyboardHandler.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.chart; import java.awt.event.KeyAdapter; @@ -28,148 +29,130 @@ public class ZoomAndPanKeyboardHandler extends KeyAdapter { if (!(source instanceof ChartPanel)) { return; } - ChartPanel chartPanel = (ChartPanel) source; + ChartPanel chartPanel = (ChartPanel)source; final double centerX = chartPanel.getBounds().getCenterX(); final double centerY = chartPanel.getBounds().getCenterY(); final Plot plot = chartPanel.getChart().getPlot(); - final Pannable pannable = plot instanceof Pannable ? (Pannable) plot - : null; - final Zoomable zoomable = plot instanceof Zoomable ? (Zoomable) plot - : null; + final Pannable pannable = plot instanceof Pannable ? (Pannable)plot : null; + final Zoomable zoomable = plot instanceof Zoomable ? (Zoomable)plot : null; switch (event.getKeyCode()) { - case KeyEvent.VK_KP_UP: - case KeyEvent.VK_NUMPAD8: - case KeyEvent.VK_UP: { - if (event.isControlDown() && null != zoomable) { - if (zoomable.getOrientation() == PlotOrientation.VERTICAL - && zoomable.isRangeZoomable()) { - chartPanel.zoomInRange(centerX, centerY); - event.consume(); - } else if (zoomable.isDomainZoomable()) { - chartPanel.zoomInDomain(centerX, centerY); - event.consume(); - } - } else if (null != pannable) { - if (pannable.getOrientation() == PlotOrientation.VERTICAL - && pannable.isRangePannable()) { - chartPanel.panRange(chartPanel.getDefaultPanFactor(), - centerX, centerY); - event.consume(); - } else if (pannable.isDomainPannable()) { - chartPanel.panDomain(chartPanel.getDefaultPanFactor(), - centerX, centerY); - event.consume(); + case KeyEvent.VK_KP_UP: + case KeyEvent.VK_NUMPAD8: + case KeyEvent.VK_UP: { + if (event.isControlDown() && null != zoomable) { + if (zoomable.getOrientation() == PlotOrientation.VERTICAL && zoomable.isRangeZoomable()) { + chartPanel.zoomInRange(centerX, centerY); + event.consume(); + } else if (zoomable.isDomainZoomable()) { + chartPanel.zoomInDomain(centerX, centerY); + event.consume(); + } + } else if (null != pannable) { + if (pannable.getOrientation() == PlotOrientation.VERTICAL && pannable.isRangePannable()) { + chartPanel.panRange(chartPanel.getDefaultPanFactor(), centerX, centerY); + event.consume(); + } else if (pannable.isDomainPannable()) { + chartPanel.panDomain(chartPanel.getDefaultPanFactor(), centerX, centerY); + event.consume(); + } } + break; } - break; - } - case KeyEvent.VK_KP_RIGHT: - case KeyEvent.VK_NUMPAD6: - case KeyEvent.VK_RIGHT: { - if (event.isControlDown() && null != zoomable) { - if (zoomable.getOrientation() == PlotOrientation.HORIZONTAL - && zoomable.isRangeZoomable()) { - chartPanel.zoomInRange(centerX, centerY); - event.consume(); - } else if (zoomable.isDomainZoomable()) { - chartPanel.zoomInDomain(centerX, centerY); - event.consume(); + case KeyEvent.VK_KP_RIGHT: + case KeyEvent.VK_NUMPAD6: + case KeyEvent.VK_RIGHT: { + if (event.isControlDown() && null != zoomable) { + if (zoomable.getOrientation() == PlotOrientation.HORIZONTAL && zoomable.isRangeZoomable()) { + chartPanel.zoomInRange(centerX, centerY); + event.consume(); + } else if (zoomable.isDomainZoomable()) { + chartPanel.zoomInDomain(centerX, centerY); + event.consume(); + } + } else if (null != pannable) { + if (pannable.getOrientation() == PlotOrientation.HORIZONTAL && pannable.isRangePannable()) { + chartPanel.panRange(chartPanel.getDefaultPanFactor(), centerX, centerY); + event.consume(); + } else if (pannable.isDomainPannable()) { + chartPanel.panDomain(chartPanel.getDefaultPanFactor(), centerX, centerY); + event.consume(); + } } - } else if (null != pannable) { - if (pannable.getOrientation() == PlotOrientation.HORIZONTAL - && pannable.isRangePannable()) { - chartPanel.panRange(chartPanel.getDefaultPanFactor(), - centerX, centerY); - event.consume(); - } else if (pannable.isDomainPannable()) { - chartPanel.panDomain(chartPanel.getDefaultPanFactor(), - centerX, centerY); - event.consume(); + break; + } + case KeyEvent.VK_KP_DOWN: + case KeyEvent.VK_NUMPAD2: + case KeyEvent.VK_DOWN: { + if (event.isControlDown() && null != zoomable) { + if (zoomable.getOrientation() == PlotOrientation.VERTICAL && zoomable.isRangeZoomable()) { + chartPanel.zoomOutRange(centerX, centerY); + event.consume(); + } else if (zoomable.isDomainZoomable()) { + chartPanel.zoomOutDomain(centerX, centerY); + event.consume(); + } + } else if (null != pannable) { + if (pannable.getOrientation() == PlotOrientation.VERTICAL && pannable.isRangePannable()) { + chartPanel.panRange(-chartPanel.getDefaultPanFactor(), centerX, centerY); + event.consume(); + } else if (pannable.isDomainPannable()) { + chartPanel.panDomain(-chartPanel.getDefaultPanFactor(), centerX, centerY); + event.consume(); + } } + break; } - break; - } - case KeyEvent.VK_KP_DOWN: - case KeyEvent.VK_NUMPAD2: - case KeyEvent.VK_DOWN: { - if (event.isControlDown() && null != zoomable) { - if (zoomable.getOrientation() == PlotOrientation.VERTICAL - && zoomable.isRangeZoomable()) { - chartPanel.zoomOutRange(centerX, centerY); - event.consume(); - } else if (zoomable.isDomainZoomable()) { - chartPanel.zoomOutDomain(centerX, centerY); - event.consume(); + case KeyEvent.VK_KP_LEFT: + case KeyEvent.VK_NUMPAD4: + case KeyEvent.VK_LEFT: { + if (event.isControlDown() && null != zoomable) { + if (zoomable.getOrientation() == PlotOrientation.HORIZONTAL && zoomable.isRangeZoomable()) { + chartPanel.zoomOutRange(centerX, centerY); + event.consume(); + } else if (zoomable.isDomainZoomable()) { + chartPanel.zoomOutDomain(centerX, centerY); + event.consume(); + } + } else if (null != pannable) { + if (pannable.getOrientation() == PlotOrientation.HORIZONTAL && pannable.isRangePannable()) { + chartPanel.panRange(-chartPanel.getDefaultPanFactor(), centerX, centerY); + event.consume(); + } else if (pannable.isDomainPannable()) { + chartPanel.panDomain(-chartPanel.getDefaultPanFactor(), centerX, centerY); + event.consume(); + } } - } else if (null != pannable) { - if (pannable.getOrientation() == PlotOrientation.VERTICAL - && pannable.isRangePannable()) { - chartPanel.panRange(-chartPanel.getDefaultPanFactor(), - centerX, centerY); - event.consume(); - } else if (pannable.isDomainPannable()) { - chartPanel.panDomain(-chartPanel.getDefaultPanFactor(), - centerX, centerY); + break; + } + // Also add browser style zooming + case KeyEvent.VK_ADD: + case KeyEvent.VK_EQUALS: { + if (event.isControlDown()) { + chartPanel.zoomInBoth(centerX, centerY); event.consume(); } + break; } - break; - } - case KeyEvent.VK_KP_LEFT: - case KeyEvent.VK_NUMPAD4: - case KeyEvent.VK_LEFT: { - if (event.isControlDown() && null != zoomable) { - if (zoomable.getOrientation() == PlotOrientation.HORIZONTAL - && zoomable.isRangeZoomable()) { - chartPanel.zoomOutRange(centerX, centerY); - event.consume(); - } else if (zoomable.isDomainZoomable()) { - chartPanel.zoomOutDomain(centerX, centerY); + case KeyEvent.VK_SUBTRACT: + case KeyEvent.VK_MINUS: { + if (event.isControlDown()) { + chartPanel.zoomOutBoth(centerX, centerY); event.consume(); } - } else if (null != pannable) { - if (pannable.getOrientation() == PlotOrientation.HORIZONTAL - && pannable.isRangePannable()) { - chartPanel.panRange(-chartPanel.getDefaultPanFactor(), - centerX, centerY); - event.consume(); - } else if (pannable.isDomainPannable()) { - chartPanel.panDomain(-chartPanel.getDefaultPanFactor(), - centerX, centerY); + break; + } + case KeyEvent.VK_NUMPAD0: { + if (event.isControlDown()) { + chartPanel.restoreAutoBounds(); event.consume(); } + break; } - break; - } - // Also add browser style zooming - case KeyEvent.VK_ADD: - case KeyEvent.VK_EQUALS: { - if (event.isControlDown()) { - chartPanel.zoomInBoth(centerX, centerY); - event.consume(); - } - break; - } - case KeyEvent.VK_SUBTRACT: - case KeyEvent.VK_MINUS: { - if (event.isControlDown()) { - chartPanel.zoomOutBoth(centerX, centerY); - event.consume(); - } - break; - } - case KeyEvent.VK_NUMPAD0: { - if (event.isControlDown()) { - chartPanel.restoreAutoBounds(); - event.consume(); - } - break; - } - default: - // Empty - break; + default: + // Empty + break; } } } diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/ZoomMouseWheelHandler.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/ZoomMouseWheelHandler.java index 195f14d23fdbb392bd4b08bc893a1143fc8920fb..aeaaf2e56c325704f1b8814eaa9dd7ed93a6c45f 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/ZoomMouseWheelHandler.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/ZoomMouseWheelHandler.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.chart; import java.awt.event.MouseWheelEvent; @@ -24,7 +25,7 @@ public class ZoomMouseWheelHandler implements MouseWheelListener { if (!(source instanceof ChartPanel)) { return; } - ChartPanel chartPanel = (ChartPanel) source; + ChartPanel chartPanel = (ChartPanel)source; if (event.isControlDown() && event.isShiftDown()) { if (event.getWheelRotation() > 0) { chartPanel.zoomOutRange(event.getX(), event.getY()); diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/axis/AxisUtils.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/axis/AxisUtils.java index 483c1c9d221210ac568978abb5f34ca8fa206f15..e820dc7039ff6d2060a2c93377d9f38cb372dacf 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/axis/AxisUtils.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/axis/AxisUtils.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.chart.axis; import java.awt.font.FontRenderContext; @@ -24,132 +25,126 @@ import org.jfree.data.Range; * Axis utilities. */ public final class AxisUtils { - public static final FontRenderContext DEFAULT_FONT_RENDER_CONTEXT = new FontRenderContext(null, true, false); + public static final FontRenderContext DEFAULT_FONT_RENDER_CONTEXT = new FontRenderContext(null, true, false); - /** - * Private constructor prevents object creation. - */ - private AxisUtils() { - // Empty - } + /** + * Private constructor prevents object creation. + */ + private AxisUtils() { + // Empty + } - /** - * Estimates the required dimension of a {@link SymbolAxis}, based on its - * {@link SymbolAxis#getSymbols()} and applies it to the axis. Uses the - * {@link #DEFAULT_FONT_RENDER_CONTEXT} to estimate. - * - * @param axis the axis to apply the fixed dimension - * @param edge the edge of the {@code axis} on the plot, see - * {@link XYPlot#getDomainAxisEdge(int)} or - * {@link XYPlot#getRangeAxisEdge(int)} - * @see ValueAxis#setFixedDimension(double) - */ - public static void calculateAndApplyFixedDimension(SymbolAxis axis, RectangleEdge edge) { - calculateAndApplyFixedDimension(axis, edge, DEFAULT_FONT_RENDER_CONTEXT); - } + /** + * Estimates the required dimension of a {@link SymbolAxis}, based on its {@link SymbolAxis#getSymbols()} and + * applies it to the axis. Uses the {@link #DEFAULT_FONT_RENDER_CONTEXT} to estimate. + * + * @param axis the axis to apply the fixed dimension + * @param edge the edge of the {@code axis} on the plot, see {@link XYPlot#getDomainAxisEdge(int)} or + * {@link XYPlot#getRangeAxisEdge(int)} + * @see ValueAxis#setFixedDimension(double) + */ + public static void calculateAndApplyFixedDimension(SymbolAxis axis, RectangleEdge edge) { + calculateAndApplyFixedDimension(axis, edge, DEFAULT_FONT_RENDER_CONTEXT); + } - /** - * Estimates the required dimension of a {@link SymbolAxis}, based on its - * {@link SymbolAxis#getSymbols()} and applies it to the axis. Uses the - * {@code frc} to estimate. - * - * @param axis the axis to apply the fixed dimension - * @param edge the edge of the {@code axis} on the plot, see - * {@link XYPlot#getDomainAxisEdge(int)} or - * {@link XYPlot#getRangeAxisEdge(int)} - * @param frc the font render context to use for the estimation - * @see ValueAxis#setFixedDimension(double) - */ - public static void calculateAndApplyFixedDimension(SymbolAxis axis, RectangleEdge edge, FontRenderContext frc) { - double fixedDimension = 0; - for (String symbol : axis.getSymbols()) { - if (null == symbol) - continue; - Rectangle2D symbolBounds = axis.getTickLabelFont().getStringBounds(symbol, frc); - fixedDimension = Math.max(fixedDimension, - RectangleEdge.isLeftOrRight(edge) ? symbolBounds.getWidth() : symbolBounds.getHeight()); - } - if (null != axis.getLabel()) { - Rectangle2D labelBounds = axis.getLabelInsets() - .createOutsetRectangle(axis.getLabelFont().getStringBounds(axis.getLabel(), frc)); - fixedDimension += RectangleEdge.isLeftOrRight(edge) ? labelBounds.getHeight() : labelBounds.getWidth(); - } - axis.setFixedDimension(fixedDimension); - } + /** + * Estimates the required dimension of a {@link SymbolAxis}, based on its {@link SymbolAxis#getSymbols()} and + * applies it to the axis. Uses the {@code frc} to estimate. + * + * @param axis the axis to apply the fixed dimension + * @param edge the edge of the {@code axis} on the plot, see {@link XYPlot#getDomainAxisEdge(int)} or + * {@link XYPlot#getRangeAxisEdge(int)} + * @param frc the font render context to use for the estimation + * @see ValueAxis#setFixedDimension(double) + */ + public static void calculateAndApplyFixedDimension(SymbolAxis axis, RectangleEdge edge, FontRenderContext frc) { + double fixedDimension = 0; + for (String symbol: axis.getSymbols()) { + if (null == symbol) { + continue; + } + Rectangle2D symbolBounds = axis.getTickLabelFont().getStringBounds(symbol, frc); + fixedDimension = Math.max(fixedDimension, + RectangleEdge.isLeftOrRight(edge) ? symbolBounds.getWidth() : symbolBounds.getHeight()); + } + if (null != axis.getLabel()) { + Rectangle2D labelBounds = axis.getLabelInsets() + .createOutsetRectangle(axis.getLabelFont().getStringBounds(axis.getLabel(), frc)); + fixedDimension += RectangleEdge.isLeftOrRight(edge) ? labelBounds.getHeight() : labelBounds.getWidth(); + } + axis.setFixedDimension(fixedDimension); + } - /** - * Estimates the required dimension of a {@link SectionAxis}, based on its - * section labels and applies it to the axis. Uses the - * {@link #DEFAULT_FONT_RENDER_CONTEXT} to estimate. - * - * @param axis the axis to apply the fixed dimension - * @param edge the edge of the {@code axis} on the plot, see - * {@link XYPlot#getDomainAxisEdge(int)} or - * {@link XYPlot#getRangeAxisEdge(int)} - * @see Section#getLabel() - * @see ValueAxis#setFixedDimension(double) - */ - public static void calculateAndApplyFixedDimension(SectionAxis axis, RectangleEdge edge) { - calculateAndApplyFixedDimension(axis, edge, DEFAULT_FONT_RENDER_CONTEXT); - } + /** + * Estimates the required dimension of a {@link SectionAxis}, based on its section labels and applies it to the + * axis. Uses the {@link #DEFAULT_FONT_RENDER_CONTEXT} to estimate. + * + * @param axis the axis to apply the fixed dimension + * @param edge the edge of the {@code axis} on the plot, see {@link XYPlot#getDomainAxisEdge(int)} or + * {@link XYPlot#getRangeAxisEdge(int)} + * @see Section#getLabel() + * @see ValueAxis#setFixedDimension(double) + */ + public static void calculateAndApplyFixedDimension(SectionAxis axis, RectangleEdge edge) { + calculateAndApplyFixedDimension(axis, edge, DEFAULT_FONT_RENDER_CONTEXT); + } - /** - * Estimates the required dimension of a {@link SectionAxis}, based on its - * section labels and applies it to the axis. Uses the {@code frc} to estimate. - * - * @param axis the axis to apply the fixed dimension - * @param edge the edge of the {@code axis} on the plot, see - * {@link XYPlot#getDomainAxisEdge(int)} or - * {@link XYPlot#getRangeAxisEdge(int)} - * @param frc the font render context to use for the estimation - * @see Section#getLabel() - * @see ValueAxis#setFixedDimension(double) - */ - public static void calculateAndApplyFixedDimension(SectionAxis axis, RectangleEdge edge, FontRenderContext frc) { - double fixedDimension = 0; - for (String sectionLabel : axis.getSections().stream().map(Section::getLabel).collect(Collectors.toList())) { - if (null == sectionLabel) - continue; - String tickLabel = axis.createTickLabel(sectionLabel); - Rectangle2D symbolBounds = axis.getTickLabelFont().getStringBounds(tickLabel, frc); - symbolBounds = axis.getTickLabelInsets().createOutsetRectangle(symbolBounds); - fixedDimension = Math.max(fixedDimension, - RectangleEdge.isLeftOrRight(edge) ? symbolBounds.getWidth() : symbolBounds.getHeight()); - } - if (null != axis.getLabel()) { - Rectangle2D labelBounds = axis.getLabelInsets() - .createOutsetRectangle(axis.getLabelFont().getStringBounds(axis.getLabel(), frc)); - fixedDimension += RectangleEdge.isLeftOrRight(edge) ? labelBounds.getHeight() : labelBounds.getWidth(); - } - axis.setFixedDimension(fixedDimension); - } + /** + * Estimates the required dimension of a {@link SectionAxis}, based on its section labels and applies it to the + * axis. Uses the {@code frc} to estimate. + * + * @param axis the axis to apply the fixed dimension + * @param edge the edge of the {@code axis} on the plot, see {@link XYPlot#getDomainAxisEdge(int)} or + * {@link XYPlot#getRangeAxisEdge(int)} + * @param frc the font render context to use for the estimation + * @see Section#getLabel() + * @see ValueAxis#setFixedDimension(double) + */ + public static void calculateAndApplyFixedDimension(SectionAxis axis, RectangleEdge edge, FontRenderContext frc) { + double fixedDimension = 0; + for (String sectionLabel: axis.getSections().stream().map(Section::getLabel).collect(Collectors.toList())) { + if (null == sectionLabel) { + continue; + } + String tickLabel = axis.createTickLabel(sectionLabel); + Rectangle2D symbolBounds = axis.getTickLabelFont().getStringBounds(tickLabel, frc); + symbolBounds = axis.getTickLabelInsets().createOutsetRectangle(symbolBounds); + fixedDimension = Math.max(fixedDimension, + RectangleEdge.isLeftOrRight(edge) ? symbolBounds.getWidth() : symbolBounds.getHeight()); + } + if (null != axis.getLabel()) { + Rectangle2D labelBounds = axis.getLabelInsets() + .createOutsetRectangle(axis.getLabelFont().getStringBounds(axis.getLabel(), frc)); + fixedDimension += RectangleEdge.isLeftOrRight(edge) ? labelBounds.getHeight() : labelBounds.getWidth(); + } + axis.setFixedDimension(fixedDimension); + } - /** - * Calculates the number of visible ticks. - * - * @return The number of visible ticks on the axis. - */ - public static int calculateVisibleTickCount(TickUnit unit, Range range) { - return (int) (Math.floor(range.getUpperBound() / unit.getSize()) - - Math.ceil(range.getLowerBound() / unit.getSize()) + 1); - } + /** + * Calculates the number of visible ticks. + * + * @return The number of visible ticks on the axis. + */ + public static int calculateVisibleTickCount(TickUnit unit, Range range) { + return (int)(Math.floor(range.getUpperBound() / unit.getSize()) + - Math.ceil(range.getLowerBound() / unit.getSize()) + 1); + } - /** - * Linear scale of a {@code value} within a {@code source} range to the - * corresponding value in the {@code target} range. - * - * @param value the value to scale - * @param source The range containing {@code value} - * @param target The range for which the {@code return} value is calculated. - * @return the scaled value - * @throws IllegalArgumentException if {@code value} is not contained by - * {@code source}, see - * {@link Range#contains(double)} - */ - public static double scaleValue(double value, Range source, Range target) { - if (!source.contains(value)) { - throw new IllegalArgumentException("Value should lie within source range"); - } - return (((value - source.getLowerBound()) / source.getLength()) * target.getLength()) + target.getLowerBound(); - } + /** + * Linear scale of a {@code value} within a {@code source} range to the corresponding value in the {@code target} + * range. + * + * @param value the value to scale + * @param source The range containing {@code value} + * @param target The range for which the {@code return} value is calculated. + * @return the scaled value + * @throws IllegalArgumentException if {@code value} is not contained by {@code source}, see + * {@link Range#contains(double)} + */ + public static double scaleValue(double value, Range source, Range target) { + if (!source.contains(value)) { + throw new IllegalArgumentException("Value should lie within source range"); + } + return (((value - source.getLowerBound()) / source.getLength()) * target.getLength()) + target.getLowerBound(); + } } diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/axis/Section.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/axis/Section.java index ce91519f1adef565352de470227fc327f3b5f389..53eeac5ce0e8099bb261a50983f2b8baec5efe58 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/axis/Section.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/axis/Section.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.chart.axis; import java.awt.Paint; @@ -21,229 +22,230 @@ import org.jfree.chart.util.Args; import org.jfree.data.Range; /** - * A section is a sub-{@link Range} on a {@link SectionAxis}. A section can have - * its own {@link ValueAxis} to scale its sub-range into the axis range. - * + * A section is a sub-{@link Range} on a {@link SectionAxis}. A section can have its own {@link ValueAxis} to scale its + * sub-range into the axis range. + * * @see SectionAxis - * @see {@link XYScaledSeries} + * @see XYScaledSeries */ public class Section implements Comparable
, Serializable, AxisChangeListener { - private static final long serialVersionUID = 1028149280898345210L; - - private final SectionAxis axis; - - private final Range range; - - private String label; - - private ValueAxis gridBandAxis; - - /** The paint used to color the grid bands (if the bands are visible). */ - private transient Paint gridBandPaint; - - /** The paint used to fill the alternate grid bands. */ - private transient Paint gridBandAlternatePaint; - - /** - * Constructs a section. - * - * @param axis the section axis that this section belongs to ({@code null} not - * permitted) - * @param range the sub-range on the {@code axis} for this section ({@code null} - * not permitted) - * @param label the section label ({@code null} permitted) - */ - public Section(SectionAxis axis, Range range, String label) { - Args.nullNotPermitted(axis, "axis"); - Args.nullNotPermitted(range, "range"); - this.axis = axis; - this.range = range; - this.label = label; - } - - /** - * Returns the section axis that this section belongs to. - * - * @return the section axis that this section belongs to (never {@code null}). - */ - public SectionAxis getAxis() { - return axis; - } - - /** - * Returns the sub-range on the section axis for this section - * - * @return the sub-range on the section axis for this section (never - * {@code null}) - */ - public Range getRange() { - return range; - } - - /** - * Returns the section label - * - * @return the section label (possibly {@code null}) - * @see #setLabel(String) - */ - public String getLabel() { - return label; - } - - /** - * Sets the label for the section. - * - * @param label the section label ({@code null} permitted) - */ - public void setLabel(String label) { - this.label = label; - fireChangeEvent(); - } - - /** - * Returns the paint for the section grid band. - * - * @return the section grid band paint (possibly {@code null}) - * @see #setGridBandPaint(Paint) - */ - public Paint getGridBandPaint() { - return gridBandPaint; - } - - /** - * Sets the paint for the section grid band. - * - * @param paint the section grid band paint ({@code null} permitted) - * @see SectionAxis#setDefaultGridBandPaint(Paint) - */ - public void setGridBandPaint(Paint paint) { - this.gridBandPaint = paint; - fireChangeEvent(); - } - - /** - * Returns the alternate paint for the section grid band. If not set, returns - * the section {@link #getGridBandPaint()}. - * - * @return the section grid band alternate paint (possibly {@code null}) - * @see #setGridBandAlternatePaint(Paint) - */ - public Paint getGridBandAlternatePaint() { - return null == this.gridBandAlternatePaint ? this.gridBandPaint : this.gridBandAlternatePaint; - } - - /** - * Sets the alternate paint for the section grid band. - * - * @param paint the section grid band alternate paint ({@code null} permitted) - * @see SectionAxis#setDefaultGridBandAlternatePaint(Paint) - */ - public void setGridBandAlternatePaint(Paint paint) { - this.gridBandAlternatePaint = paint; - fireChangeEvent(); - } - - /** - * A convenience method that sets a new {@link NumberAxis} with a - * gridBandRange and optionally configured to show integer ticks - * only. - * - * @param gridBandRange the range to set on this grid band axis - * @param isInteger if treu the grid band axis show integer - * ticks only - * @see #setGridBandAxis(ValueAxis) - * @see NumberAxis#createIntegerTickUnits() - * @see XYScaledSeries - */ - public void setGridBandNumberRange(Range gridBandRange, boolean isInteger) { - NumberAxis axis = new NumberAxis(this.label); - if (isInteger) { - axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); - } - axis.setMinorTickCount(1); - axis.setRange(gridBandRange, true, false); - setGridBandAxis(axis); - } - - /** - * Returns the {@link ValueAxis} to be rendered on the section of the - * {@link SectionAxis}, {@code null} if not applicable. - * - * @return the section grid band axis (possibly {@code null}) - * @see #setGridBandAxis(ValueAxis) - */ - public ValueAxis getGridBandAxis() { - return this.gridBandAxis; - } - - /** - * Set the {@link ValueAxis} to be rendered on the section of the - * {@link SectionAxis}, {@code null} if not applicable. - * - * @param axis the grid band axis ({@code null} permitted) - */ - public void setGridBandAxis(ValueAxis axis) { - if (null != this.gridBandAxis) { - this.gridBandAxis.removeChangeListener(this); - } - this.gridBandAxis = axis; - if (null != this.gridBandAxis) { - this.gridBandAxis.addChangeListener(this); - } - fireChangeEvent(); - } - - @Override - public void axisChanged(AxisChangeEvent event) { - fireChangeEvent(); - } - - /** - * Sends an {@link AxisChangeEvent} to all registered listeners of the - * {@link SectionAxis}. - */ - protected void fireChangeEvent() { - axis.sectionChanged(this); - } - - @Override - public int compareTo(Section o) { - return Double.compare(getRange().getCentralValue(), o.getRange().getCentralValue()); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + ((axis == null) ? 0 : axis.hashCode()); - result = prime * result + ((range == null) ? 0 : range.hashCode()); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Section other = (Section) obj; - if (axis == null) { - if (other.axis != null) - return false; - } else if (!axis.equals(other.axis)) - return false; - if (range == null) { - if (other.range != null) - return false; - } else if (!range.equals(other.range)) - return false; - return true; - } - - @Override - public String toString() { - return label; - } -} \ No newline at end of file + private static final long serialVersionUID = 1028149280898345210L; + + private final SectionAxis axis; + + private final Range range; + + private String label; + + private ValueAxis gridBandAxis; + + /** The paint used to color the grid bands (if the bands are visible). */ + private transient Paint gridBandPaint; + + /** The paint used to fill the alternate grid bands. */ + private transient Paint gridBandAlternatePaint; + + /** + * Constructs a section. + * + * @param axis the section axis that this section belongs to ({@code null} not permitted) + * @param range the sub-range on the {@code axis} for this section ({@code null} not permitted) + * @param label the section label ({@code null} permitted) + */ + public Section(SectionAxis axis, Range range, String label) { + Args.nullNotPermitted(axis, "axis"); + Args.nullNotPermitted(range, "range"); + this.axis = axis; + this.range = range; + this.label = label; + } + + /** + * Returns the section axis that this section belongs to. + * + * @return the section axis that this section belongs to (never {@code null}). + */ + public SectionAxis getAxis() { + return axis; + } + + /** + * Returns the sub-range on the section axis for this section + * + * @return the sub-range on the section axis for this section (never {@code null}) + */ + public Range getRange() { + return range; + } + + /** + * Returns the section label + * + * @return the section label (possibly {@code null}) + * @see #setLabel(String) + */ + public String getLabel() { + return label; + } + + /** + * Sets the label for the section. + * + * @param label the section label ({@code null} permitted) + */ + public void setLabel(String label) { + this.label = label; + fireChangeEvent(); + } + + /** + * Returns the paint for the section grid band. + * + * @return the section grid band paint (possibly {@code null}) + * @see #setGridBandPaint(Paint) + */ + public Paint getGridBandPaint() { + return gridBandPaint; + } + + /** + * Sets the paint for the section grid band. + * + * @param paint the section grid band paint ({@code null} permitted) + * @see SectionAxis#setDefaultGridBandPaint(Paint) + */ + public void setGridBandPaint(Paint paint) { + this.gridBandPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the alternate paint for the section grid band. If not set, returns the section + * {@link #getGridBandPaint()}. + * + * @return the section grid band alternate paint (possibly {@code null}) + * @see #setGridBandAlternatePaint(Paint) + */ + public Paint getGridBandAlternatePaint() { + return null == this.gridBandAlternatePaint ? this.gridBandPaint : this.gridBandAlternatePaint; + } + + /** + * Sets the alternate paint for the section grid band. + * + * @param paint the section grid band alternate paint ({@code null} permitted) + * @see SectionAxis#setDefaultGridBandAlternatePaint(Paint) + */ + public void setGridBandAlternatePaint(Paint paint) { + this.gridBandAlternatePaint = paint; + fireChangeEvent(); + } + + /** + * A convenience method that sets a new {@link NumberAxis} with a gridBandRange and optionally + * configured to show integer ticks only. + * + * @param gridBandRange the range to set on this grid band axis + * @param isInteger if treu the grid band axis show integer ticks only + * @see #setGridBandAxis(ValueAxis) + * @see NumberAxis#createIntegerTickUnits() + * @see XYScaledSeries + */ + public void setGridBandNumberRange(Range gridBandRange, boolean isInteger) { + NumberAxis axis = new NumberAxis(this.label); + if (isInteger) { + axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); + } + axis.setMinorTickCount(1); + axis.setRange(gridBandRange, true, false); + setGridBandAxis(axis); + } + + /** + * Returns the {@link ValueAxis} to be rendered on the section of the {@link SectionAxis}, {@code null} if not + * applicable. + * + * @return the section grid band axis (possibly {@code null}) + * @see #setGridBandAxis(ValueAxis) + */ + public ValueAxis getGridBandAxis() { + return this.gridBandAxis; + } + + /** + * Set the {@link ValueAxis} to be rendered on the section of the {@link SectionAxis}, {@code null} if not + * applicable. + * + * @param axis the grid band axis ({@code null} permitted) + */ + public void setGridBandAxis(ValueAxis axis) { + if (null != this.gridBandAxis) { + this.gridBandAxis.removeChangeListener(this); + } + this.gridBandAxis = axis; + if (null != this.gridBandAxis) { + this.gridBandAxis.addChangeListener(this); + } + fireChangeEvent(); + } + + @Override + public void axisChanged(AxisChangeEvent event) { + fireChangeEvent(); + } + + /** + * Sends an {@link AxisChangeEvent} to all registered listeners of the {@link SectionAxis}. + */ + protected void fireChangeEvent() { + axis.sectionChanged(this); + } + + @Override + public int compareTo(Section o) { + return Double.compare(getRange().getCentralValue(), o.getRange().getCentralValue()); + } + + @Override + public int hashCode() { + final int prime = 31; + int result = 1; + result = prime * result + ((axis == null) ? 0 : axis.hashCode()); + result = prime * result + ((range == null) ? 0 : range.hashCode()); + return result; + } + + @Override + public boolean equals(Object obj) { + if (this == obj) { + return true; + } + if (obj == null) { + return false; + } + if (getClass() != obj.getClass()) { + return false; + } + Section other = (Section)obj; + if (axis == null) { + if (other.axis != null) { + return false; + } + } else if (!axis.equals(other.axis)) { + return false; + } + if (range == null) { + if (other.range != null) { + return false; + } + } else if (!range.equals(other.range)) { + return false; + } + return true; + } + + @Override + public String toString() { + return label; + } +} diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/axis/SectionAxis.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/axis/SectionAxis.java index 0a6ee5f5bcabb750602d479c68290190d3562f8f..07aef42aea632dee9805230c1a64f09ab0b6d935 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/axis/SectionAxis.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/axis/SectionAxis.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.chart.axis; import java.awt.BasicStroke; @@ -44,739 +45,712 @@ import org.jfree.chart.util.Args; import org.jfree.data.Range; /** - * An {@link Axis} that stacks multiple axes into a single axis, creating - * {@link Section}s. Use this axis to combine e.g. {@link NumberAxis} and - * {@link SymbolAxis} in a single axis. + * An {@link Axis} that stacks multiple axes into a single axis, creating {@link Section}s. Use this axis to combine + * e.g. {@link NumberAxis} and {@link SymbolAxis} in a single axis. */ public class SectionAxis extends ValueAxis { - private static final long serialVersionUID = 6418801819447160805L; - - public enum TooltipMode { - /** - * Don't use tooltips. - */ - NEVER, - /** - * Always show tooltips. - */ - ALWAYS, - /** - * Default: Show tooltips only when label exceeds - * {@link SectionsAxis#setTickLabelMaxLength(int)}. - */ - MAX_EXCEEDED - }; - - /** The default grid band paint. */ - public static final Paint DEFAULT_GRID_BAND_PAINT = new Color(232, 234, 232, 128); - - /** The default paint for alternate grid bands. */ - public static final Paint DEFAULT_GRID_BAND_ALTERNATE_PAINT = new Color(0, 0, 0, 0); // transparent - - /** The default value for the lower margin (0%). */ - public static final double DEFAULT_LOWER_MARGIN = 0; - - /** The default value for the upper margin (0%). */ - public static final double DEFAULT_UPPER_MARGIN = 0; - - public static final double DEFAULT_SECTION_LENGTH = 1; - - public static final double DEFAULT_SECTION_GAP = 0; - - public static final int NO_TICK_LABEL_MAX_LENGTH = -1; - - private final LinkedList
sections = new LinkedList<>(); - - private double defaultSectionGap; - - private int tickLabelMaxLength; - - private TooltipMode tooltipMode; - - /** Flag that indicates whether or not grid bands are visible. */ - private boolean gridBandsVisible; - - /** The paint used to color the grid bands (if the bands are visible). */ - private transient Paint defaultGridBandPaint; - - /** The paint used to fill the alternate grid bands. */ - private transient Paint defaultGridBandAlternatePaint; - - /** - * Default constructor. - */ - public SectionAxis() { - this(null); - } - - /** - * Constructs a section axis, using default values where necessary. - * - * @param label the axis label ({@code null} permitted). - */ - public SectionAxis(String label) { - super(label, new StandardTickUnitSource()); - setLowerMargin(DEFAULT_LOWER_MARGIN); - setUpperMargin(DEFAULT_UPPER_MARGIN); - this.gridBandsVisible = true; - this.defaultGridBandPaint = DEFAULT_GRID_BAND_PAINT; - this.defaultGridBandAlternatePaint = DEFAULT_GRID_BAND_ALTERNATE_PAINT; - this.defaultSectionGap = DEFAULT_SECTION_GAP; - this.tickLabelMaxLength = NO_TICK_LABEL_MAX_LENGTH; - this.tooltipMode = TooltipMode.MAX_EXCEEDED; - } - - /** - * Get the maximum number of section label characters visible. - * - * @return the maximum number of section label characters visible - * @see #setTickLabelMaxLength(int) - */ - public int getTickLabelMaxLength() { - return tickLabelMaxLength; - } - - /** - * Set the maximum number of section label characters visible. If a section - * label is longer, its name will be clipped to {@link #getTickLabelMaxLength()} - * and post-fixed with '...'. - * - * @param tickLabelMaxLength a positive number or - * {@link #NO_TICK_LABEL_MAX_LENGTH}. - */ - public void setTickLabelMaxLength(int tickLabelMaxLength) { - this.tickLabelMaxLength = tickLabelMaxLength; - fireChangeEvent(); - } - - /** - * Creates a tick label that adheres to the restrictions of this - * {@link SectionAxis} - * - * @param sectionLabel the label to format - * @return a tick label that adheres to the restrictions of this - * {@link SectionAxis} - * @see #setTickLabelMaxLength(int) - */ - protected String createTickLabel(String sectionLabel) { - if (null == sectionLabel || tickLabelMaxLength < 0 || sectionLabel.length() <= tickLabelMaxLength) { - return sectionLabel; - } - return sectionLabel.substring(0, tickLabelMaxLength) + "..."; - } - - /** - * Returns the {@link TooltipMode} to use for this axis. - * - * @return the {@link TooltipMode} to use for this axis. - * @see #setTooltipMode(TooltipMode) - */ - public TooltipMode getTooltipMode() { - return tooltipMode; - } - - /** - * Sets the {@link TooltipMode} to use for this axis. - * - * @param tooltipMode the {@link TooltipMode} to use for this axis. - * @see TooltipMode - */ - public void setTooltipMode(TooltipMode tooltipMode) { - Args.nullNotPermitted(tooltipMode, "TooltipMode"); - this.tooltipMode = tooltipMode; - } - - /** - * Returns true if the grid bands are showing, and - * false otherwise. - * - * @return true if the grid bands are showing, and - * false otherwise. - * - * @see #setGridBandsVisible(boolean) - */ - public boolean isGridBandsVisible() { - return this.gridBandsVisible; - } - - /** - * Sets the visibility of the grid bands and notifies registered listeners that - * the axis has been modified. - * - * @param flag the new setting. - * - * @see #isGridBandsVisible() - */ - public void setGridBandsVisible(boolean flag) { - this.gridBandsVisible = flag; - fireChangeEvent(); - } - - /** - * Returns the paint used to color the grid bands. - * - * @return The grid band paint (never null). - * - * @see #setDefaultGridBandPaint(Paint) - * @see #isGridBandsVisible() - */ - public Paint getDefaultGridBandPaint() { - return this.defaultGridBandPaint; - } - - /** - * Sets the grid band paint and sends an {@link AxisChangeEvent} to all - * registered listeners. - * - * @param paint the paint (null not permitted). - * - * @see #getDefaultGridBandPaint() - */ - public void setDefaultGridBandPaint(Paint paint) { - Args.nullNotPermitted(paint, "paint"); - this.defaultGridBandPaint = paint; - fireChangeEvent(); - } - - /** - * Returns the paint used for the grid band of the section. - * - * @return The paint (never null). - * - * @see #setDefaultGridBandPaint(Paint) - * @see Section#setGridBandPaint(Paint) - */ - protected Paint getGridBandPaint(Section section) { - Args.nullNotPermitted(section, "section"); - Paint paint = section.getGridBandPaint(); - if (paint == null) { - paint = getDefaultGridBandPaint(); - } - return paint; - } - - /** - * Returns the paint used for alternate grid bands. - * - * @return The paint (never null). - * - * @see #setDefaultGridBandAlternatePaint(Paint) - * @see #isGridBandsVisible() - */ - public Paint getDefaultGridBandAlternatePaint() { - return this.defaultGridBandAlternatePaint; - } - - /** - * Sets the paint used for alternate grid bands and sends a - * {@link AxisChangeEvent} to all registered listeners. - * - * @param paint the paint (null not permitted). - * - * @see #getDefaultGridBandAlternatePaint() - * @see #setDefaultGridBandPaint(Paint) - */ - public void setDefaultGridBandAlternatePaint(Paint paint) { - Args.nullNotPermitted(paint, "paint"); - this.defaultGridBandAlternatePaint = paint; - fireChangeEvent(); - } - - /** - * Returns the paint used for the alternate grid band of the section. - * - * @return The paint (never null). - * - * @see #setDefaultGridBandAlternatePaint(Paint) - * @see Section#setGridBandAlternatePaint(Paint) - */ - protected Paint getGridBandAlternatePaint(Section section) { - Args.nullNotPermitted(section, "section"); - Paint paint = section.getGridBandAlternatePaint(); - if (paint == null) { - paint = getDefaultGridBandAlternatePaint(); - } - return paint; - } - - /** - * Returns the absolute gap value to use between sections. - * - * @return the absolute gap value to use between sections. - * @see #setDefaultSectionGap(double) - */ - public double getDefaultSectionGap() { - return defaultSectionGap; - } - - /** - * Sets the absolute gap value to use between sections. - * - * @param sectionGap the absolute gap value to use between sections. - */ - public void setDefaultSectionGap(double sectionGap) { - this.defaultSectionGap = sectionGap; - } - - /** - * Returns an unmodifiable {@link List} containing all {@link Section}s that are - * currently contained by this axis. - * - * @return all {@link Section}s that are currently contained by this axis. - * @see #nextSection(String, double, double) - */ - public List
getSections() { - return Collections.unmodifiableList(sections); - } - - /** - * Creates and adds a new {@link Section} to this axis with the specified - * label, {@link #DEFAULT_SECTION_LENGTH} and - * {@link #getDefaultSectionGap()}. - * - * @param label the label for the section - * @return the created section - */ - public Section nextSection(String label) { - return nextSection(label, DEFAULT_SECTION_LENGTH, defaultSectionGap); - } - - /** - * Creates and adds a new {@link Section} to this axis with the specified - * label, length and {@link #getDefaultSectionGap()}. - * - * @param label the label for the section - * @param length the length of the section on this axis - * @return the created section - */ - public Section nextSection(String label, double length) { - return nextSection(label, length, defaultSectionGap); - } - - /** - * Creates and adds a new {@link Section} to this axis with the specified - * label, length and gap. - * - * @param label the label for the section - * @param length the length of the section on this axis (must be greater than zero) - * @param gap the gap between the section and the previous section on this - * axis (must be 0.0 or higher) - * @return the created section - */ - public Section nextSection(String label, double length, double gap) { - Args.requireGreaterThanZero(length, "length"); - Args.requireNonNegative(gap, "gap"); - double sectionLowerBound = 0; - if (!sections.isEmpty()) { - sectionLowerBound = sections.getLast().getRange().getUpperBound() + gap; - } - Section section = new Section(this, new Range(sectionLowerBound, sectionLowerBound + length), label); - sections.add(section); - return section; - } - - /** - * Receives notification of a section change. - * - * @param section the section. - */ - protected void sectionChanged(Section section) { - fireChangeEvent(); - } - - - @Override - public double valueToJava2D(double value, Rectangle2D area, RectangleEdge edge) { - Range range = getRange(); - double axisMin = range.getLowerBound(); - double axisMax = range.getUpperBound(); - - double min = 0.0; - double max = 0.0; - if (RectangleEdge.isTopOrBottom(edge)) { - min = area.getX(); - max = area.getMaxX(); - } else if (RectangleEdge.isLeftOrRight(edge)) { - max = area.getMinY(); - min = area.getMaxY(); - } - if (isInverted()) { - return max - ((value - axisMin) / (axisMax - axisMin)) * (max - min); - } else { - return min + ((value - axisMin) / (axisMax - axisMin)) * (max - min); - } - } - - @Override - public double java2DToValue(double java2dValue, Rectangle2D area, RectangleEdge edge) { - Range range = getRange(); - double axisMin = range.getLowerBound(); - double axisMax = range.getUpperBound(); - - double min = 0.0; - double max = 0.0; - if (RectangleEdge.isTopOrBottom(edge)) { - min = area.getX(); - max = area.getMaxX(); - } else if (RectangleEdge.isLeftOrRight(edge)) { - min = area.getMaxY(); - max = area.getY(); - } - if (isInverted()) { - return axisMax - (java2dValue - min) / (max - min) * (axisMax - axisMin); - } else { - return axisMin + (java2dValue - min) / (max - min) * (axisMax - axisMin); - } - } - - @Override - public void configure() { - if (isAutoRange()) { - autoAdjustRange(); - } - } - - @Override - public Range calculateAutoRange(boolean adhereToMax) { - // no plot, no data - if (getPlot() instanceof ValueAxisPlot) { - // ensure that all the sections are displayed - double lower; - double upper; - if (sections.isEmpty()) { - Range r = getDefaultAutoRange(); - lower = r.getLowerBound(); - upper = r.getUpperBound(); - } else { - lower = sections.getFirst().getRange().getLowerBound(); - upper = sections.getLast().getRange().getUpperBound(); - } - - double fixedAutoRange = getFixedAutoRange(); - if (adhereToMax && fixedAutoRange > 0.0) { - Range aligned = getAutoRangeAlign().align(new Range(lower, upper), fixedAutoRange); - lower = aligned.getLowerBound(); - upper = aligned.getUpperBound(); - } else { - double range = upper - lower; - // ensure the auto-range is at least in size... - double minRange = getAutoRangeMinimumSize(); - if (range < minRange) { - upper = (upper + lower + minRange) / 2; - lower = (upper + lower - minRange) / 2; - } - - // Add the margins - upper += upper * getUpperMargin(); - lower -= lower * getLowerMargin(); - } - - return new Range(lower, upper); - } - return null; - } - - @Override - public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, - PlotRenderingInfo plotState) { - // draw the tick marks and labels... - AxisState state = drawTickMarksAndLabels(g2, cursor, plotArea, dataArea, edge); - - if (this.gridBandsVisible) { - drawGridBands(g2, plotArea, dataArea, edge); - } - - if (getAttributedLabel() != null) { - state = drawAttributedLabel(getAttributedLabel(), g2, plotArea, dataArea, edge, state); - - } else { - state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state); - } - createAndAddEntity(cursor, state, dataArea, edge, plotState); - createTickLabelEntities(g2, cursor, state, dataArea, edge, plotState); - - return state; - } - - /** - * Creates the {@link TickLabelEntity}s for this axis. - * - * @param g2 the graphics device ({@code null} not permitted). - * @param cursor the initial cursor value. - * @param state the axis state after completion of the drawing with a - * possibly updated cursor position. - * @param dataArea the data area. - * @param edge the edge ({@code null} not permitted). - * @param plotState the PlotRenderingInfo from which a reference to the entity - * collection can be obtained. - */ - protected void createTickLabelEntities(Graphics2D g2, double cursor, AxisState state, Rectangle2D dataArea, - RectangleEdge edge, PlotRenderingInfo plotState) { - if (plotState == null || plotState.getOwner() == null || plotState.getOwner().getEntityCollection() == null) { - return; // no need to create entity if we can't save it anyways... - } - EntityCollection entityCollection = plotState.getOwner().getEntityCollection(); - for (Object tick : state.getTicks()) { - if (tick instanceof SectionTick && ((SectionTick) tick).getTooltipText() != null) { - Shape tickTextBounds = calculateTickTextBounds((SectionTick) tick, g2, cursor, dataArea, edge); - entityCollection.add(new TickLabelEntity(tickTextBounds, ((SectionTick) tick).getTooltipText(), null)); - } - } - } - - /** - * Draws the grid bands. Alternate bands are colored using - * gridBandPaint (DEFAULT_GRID_BAND_PAINT by default). - * - * @param g2 the graphics target (null not permitted). - * @param plotArea the area within which the plot is drawn (null - * not permitted). - * @param dataArea the data area to which the axes are aligned - * (null not permitted). - * @param edge the edge to which the axis is aligned (null not - * permitted). - */ - protected void drawGridBands(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge) { - Shape savedClip = g2.getClip(); - g2.clip(dataArea); - if (RectangleEdge.isTopOrBottom(edge)) { - drawGridBandsHorizontal(g2, plotArea, dataArea, edge); - } else if (RectangleEdge.isLeftOrRight(edge)) { - drawGridBandsVertical(g2, plotArea, dataArea, edge); - } - g2.setClip(savedClip); - } - - /** - * Draws the grid bands for the axis when it is at the top or bottom of the - * plot. - * - * @param g2 the graphics target (null not permitted). - * @param plotArea the area within which the plot is drawn (not used here). - * @param dataArea the area for the data (to which the axes are aligned, - * null not permitted). - * @param edge the edge to which the axis is aligned (null not - * permitted). - */ - protected void drawGridBandsHorizontal(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, - RectangleEdge edge) { - throw new UnsupportedOperationException("This axis does not support horizontal plotting yet!"); - } - - /** - * Draws the grid bands for an axis that is aligned to the left or right of the - * data area (that is, a vertical axis). - * - * @param g2 the graphics target (null not - * permitted). - * @param plotArea the area within which the plot is drawn (not used - * here). - * @param dataArea the area for the data (to which the axes are - * aligned, null not permitted). - * @param firstGridBandIsDark True: the first grid band takes the color of - * gridBandPaint. False: the second grid - * band takes the color of - * gridBandPaint. - * @param ticks a list of ticks (null not permitted). - */ - protected void drawGridBandsVertical(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, - RectangleEdge edge) { - - boolean useAlternatePaint = true; - double xx = dataArea.getX(); - double yMax, yMin; - - // gets the outline stroke width of the plot - double outlineStrokeWidth = 1.0; - Stroke outlineStroke = getPlot().getOutlineStroke(); - if (outlineStroke != null && outlineStroke instanceof BasicStroke) { - outlineStrokeWidth = ((BasicStroke) outlineStroke).getLineWidth(); - } - - for (Section section : sections) { - if (!getRange().intersects(section.getRange())) { - continue; - } - - yMin = valueToJava2D(section.getRange().getLowerBound(), dataArea, RectangleEdge.LEFT); - yMax = valueToJava2D(section.getRange().getUpperBound(), dataArea, RectangleEdge.LEFT); - - g2.setPaint(useAlternatePaint ? getGridBandAlternatePaint(section) : getGridBandPaint(section)); - useAlternatePaint = !useAlternatePaint; - - Rectangle2D band = new Rectangle2D.Double(xx + outlineStrokeWidth, Math.min(yMin, yMax), - dataArea.getMaxX() - xx - outlineStrokeWidth, Math.abs(yMax - yMin)); - g2.fill(band); - } - } - - @Override - public List refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) { - if (RectangleEdge.isTopOrBottom(edge)) { - return refreshTicksHorizontal(g2, dataArea, edge); - } else if (RectangleEdge.isLeftOrRight(edge)) { - return refreshTicksVertical(g2, dataArea, edge); - } else { - return Collections.emptyList(); - } - } - - /** - * Calculates the positions of the tick labels for the axis, storing the results - * in the tick label list (ready for drawing). This method is called when the - * axis is at the top or bottom of the chart (so the axis is "horizontal"). - * - * @param g2 the graphics device. - * @param dataArea the area in which the plot should be drawn. - * @param edge the location of the axis. - * - * @return The ticks. - */ - protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { - throw new UnsupportedOperationException("This axis does not support horizontal plotting yet!"); - } - - /** - * Calculates the positions of the tick labels for the axis, storing the results - * in the tick label list (ready for drawing). This method is called when the - * axis is at the left or right of the chart (so the axis is "vertical"). - * - * @param g2 the graphics device. - * @param dataArea the area in which the plot should be drawn. - * @param edge the location of the axis. - * - * @return The ticks. - */ - protected List refreshTicksVertical(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { - Font tickLabelFont = getTickLabelFont(); - g2.setFont(tickLabelFont); - - double cursor = 0.0; - TextAnchor textAnchor; - TextAnchor rotationAnchor; - double angle; - if (isVerticalTickLabels()) { - if (edge == RectangleEdge.LEFT) { - textAnchor = TextAnchor.BOTTOM_CENTER; - rotationAnchor = TextAnchor.BOTTOM_CENTER; - angle = -Math.PI / 2.0; - } else { - textAnchor = TextAnchor.BOTTOM_CENTER; - rotationAnchor = TextAnchor.BOTTOM_CENTER; - angle = Math.PI / 2.0; - } - } else { - if (edge == RectangleEdge.LEFT) { - textAnchor = TextAnchor.CENTER_RIGHT; - rotationAnchor = TextAnchor.CENTER_RIGHT; - angle = 0.0; - } else { - textAnchor = TextAnchor.CENTER_LEFT; - rotationAnchor = TextAnchor.CENTER_LEFT; - angle = 0.0; - } - } - - // Creating the ticks and check if labels do not overlap - List ticks = new ArrayList<>(); - Area ticksTextArea = new Area(); - - for (Section section : sections) { - if (!getRange().contains(section.getRange().getCentralValue())) { - continue; - } - SectionTick sectionTick = createSectionTick(TickType.MINOR, section.getRange().getCentralValue(), - section.getLabel(), textAnchor, rotationAnchor, angle); - // Avoid to draw overlapping ticks labels - Shape tickTextBounds = calculateTickTextBounds(sectionTick, g2, cursor, dataArea, edge); - if (!intersect(ticksTextArea, tickTextBounds)) { - ticksTextArea.add(new Area(tickTextBounds)); - ticks.add(sectionTick); - } - } - - for (Section section : sections) { - ValueAxis gridBandAxis = section.getGridBandAxis(); - if (null == gridBandAxis) { - continue; - } - - Range sectionRange = section.getRange(); - double yLower = valueToJava2D(sectionRange.getLowerBound(), dataArea, edge); - double yUpper = valueToJava2D(sectionRange.getUpperBound(), dataArea, edge); - // Calculate ticks for the scaled data area - Rectangle2D sectionDataArea = new Rectangle2D.Double(dataArea.getX(), yLower, dataArea.getWidth(), - Math.abs(yUpper - yLower)); + private static final long serialVersionUID = 6418801819447160805L; + + public enum TooltipMode { + /** + * Don't use tooltips. + */ + NEVER, + /** + * Always show tooltips. + */ + ALWAYS, + /** + * Default: Show tooltips only when label exceeds {@link SectionsAxis#setTickLabelMaxLength(int)}. + */ + MAX_EXCEEDED + } + + /** The default grid band paint. */ + public static final Paint DEFAULT_GRID_BAND_PAINT = new Color(232, 234, 232, 128); + + /** The default paint for alternate grid bands. */ + public static final Paint DEFAULT_GRID_BAND_ALTERNATE_PAINT = new Color(0, 0, 0, 0); // transparent + + /** The default value for the lower margin (0%). */ + public static final double DEFAULT_LOWER_MARGIN = 0; + + /** The default value for the upper margin (0%). */ + public static final double DEFAULT_UPPER_MARGIN = 0; + + public static final double DEFAULT_SECTION_LENGTH = 1; + + public static final double DEFAULT_SECTION_GAP = 0; + + public static final int NO_TICK_LABEL_MAX_LENGTH = -1; + + private final LinkedList
sections = new LinkedList<>(); + + private double defaultSectionGap; + + private int tickLabelMaxLength; + + private TooltipMode tooltipMode; + + /** Flag that indicates whether or not grid bands are visible. */ + private boolean gridBandsVisible; + + /** The paint used to color the grid bands (if the bands are visible). */ + private transient Paint defaultGridBandPaint; + + /** The paint used to fill the alternate grid bands. */ + private transient Paint defaultGridBandAlternatePaint; + + /** + * Default constructor. + */ + public SectionAxis() { + this(null); + } + + /** + * Constructs a section axis, using default values where necessary. + * + * @param label the axis label ({@code null} permitted). + */ + public SectionAxis(String label) { + super(label, new StandardTickUnitSource()); + setLowerMargin(DEFAULT_LOWER_MARGIN); + setUpperMargin(DEFAULT_UPPER_MARGIN); + this.gridBandsVisible = true; + this.defaultGridBandPaint = DEFAULT_GRID_BAND_PAINT; + this.defaultGridBandAlternatePaint = DEFAULT_GRID_BAND_ALTERNATE_PAINT; + this.defaultSectionGap = DEFAULT_SECTION_GAP; + this.tickLabelMaxLength = NO_TICK_LABEL_MAX_LENGTH; + this.tooltipMode = TooltipMode.MAX_EXCEEDED; + } + + /** + * Get the maximum number of section label characters visible. + * + * @return the maximum number of section label characters visible + * @see #setTickLabelMaxLength(int) + */ + public int getTickLabelMaxLength() { + return tickLabelMaxLength; + } + + /** + * Set the maximum number of section label characters visible. If a section label is longer, its name will be + * clipped to {@link #getTickLabelMaxLength()} and post-fixed with '...'. + * + * @param tickLabelMaxLength a positive number or {@link #NO_TICK_LABEL_MAX_LENGTH}. + */ + public void setTickLabelMaxLength(int tickLabelMaxLength) { + this.tickLabelMaxLength = tickLabelMaxLength; + fireChangeEvent(); + } + + /** + * Creates a tick label that adheres to the restrictions of this {@link SectionAxis} + * + * @param sectionLabel the label to format + * @return a tick label that adheres to the restrictions of this {@link SectionAxis} + * @see #setTickLabelMaxLength(int) + */ + protected String createTickLabel(String sectionLabel) { + if (null == sectionLabel || tickLabelMaxLength < 0 || sectionLabel.length() <= tickLabelMaxLength) { + return sectionLabel; + } + return sectionLabel.substring(0, tickLabelMaxLength) + "..."; + } + + /** + * Returns the {@link TooltipMode} to use for this axis. + * + * @return the {@link TooltipMode} to use for this axis. + * @see #setTooltipMode(TooltipMode) + */ + public TooltipMode getTooltipMode() { + return tooltipMode; + } + + /** + * Sets the {@link TooltipMode} to use for this axis. + * + * @param tooltipMode the {@link TooltipMode} to use for this axis. + * @see TooltipMode + */ + public void setTooltipMode(TooltipMode tooltipMode) { + Args.nullNotPermitted(tooltipMode, "TooltipMode"); + this.tooltipMode = tooltipMode; + } + + /** + * Returns true if the grid bands are showing, and false otherwise. + * + * @return true if the grid bands are showing, and false otherwise. + * + * @see #setGridBandsVisible(boolean) + */ + public boolean isGridBandsVisible() { + return this.gridBandsVisible; + } + + /** + * Sets the visibility of the grid bands and notifies registered listeners that the axis has been modified. + * + * @param flag the new setting. + * + * @see #isGridBandsVisible() + */ + public void setGridBandsVisible(boolean flag) { + this.gridBandsVisible = flag; + fireChangeEvent(); + } + + /** + * Returns the paint used to color the grid bands. + * + * @return The grid band paint (never null). + * + * @see #setDefaultGridBandPaint(Paint) + * @see #isGridBandsVisible() + */ + public Paint getDefaultGridBandPaint() { + return this.defaultGridBandPaint; + } + + /** + * Sets the grid band paint and sends an {@link AxisChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getDefaultGridBandPaint() + */ + public void setDefaultGridBandPaint(Paint paint) { + Args.nullNotPermitted(paint, "paint"); + this.defaultGridBandPaint = paint; + fireChangeEvent(); + } + + /** + * Returns the paint used for the grid band of the section. + * + * @return The paint (never null). + * + * @see #setDefaultGridBandPaint(Paint) + * @see Section#setGridBandPaint(Paint) + */ + protected Paint getGridBandPaint(Section section) { + Args.nullNotPermitted(section, "section"); + Paint paint = section.getGridBandPaint(); + if (paint == null) { + paint = getDefaultGridBandPaint(); + } + return paint; + } + + /** + * Returns the paint used for alternate grid bands. + * + * @return The paint (never null). + * + * @see #setDefaultGridBandAlternatePaint(Paint) + * @see #isGridBandsVisible() + */ + public Paint getDefaultGridBandAlternatePaint() { + return this.defaultGridBandAlternatePaint; + } + + /** + * Sets the paint used for alternate grid bands and sends a {@link AxisChangeEvent} to all registered listeners. + * + * @param paint the paint (null not permitted). + * + * @see #getDefaultGridBandAlternatePaint() + * @see #setDefaultGridBandPaint(Paint) + */ + public void setDefaultGridBandAlternatePaint(Paint paint) { + Args.nullNotPermitted(paint, "paint"); + this.defaultGridBandAlternatePaint = paint; + fireChangeEvent(); + } + + /** + * Returns the paint used for the alternate grid band of the section. + * + * @return The paint (never null). + * + * @see #setDefaultGridBandAlternatePaint(Paint) + * @see Section#setGridBandAlternatePaint(Paint) + */ + protected Paint getGridBandAlternatePaint(Section section) { + Args.nullNotPermitted(section, "section"); + Paint paint = section.getGridBandAlternatePaint(); + if (paint == null) { + paint = getDefaultGridBandAlternatePaint(); + } + return paint; + } + + /** + * Returns the absolute gap value to use between sections. + * + * @return the absolute gap value to use between sections. + * @see #setDefaultSectionGap(double) + */ + public double getDefaultSectionGap() { + return defaultSectionGap; + } + + /** + * Sets the absolute gap value to use between sections. + * + * @param sectionGap the absolute gap value to use between sections. + */ + public void setDefaultSectionGap(double sectionGap) { + this.defaultSectionGap = sectionGap; + } + + /** + * Returns an unmodifiable {@link List} containing all {@link Section}s that are currently contained by this axis. + * + * @return all {@link Section}s that are currently contained by this axis. + * @see #nextSection(String, double, double) + */ + public List
getSections() { + return Collections.unmodifiableList(sections); + } + + /** + * Creates and adds a new {@link Section} to this axis with the specified label, + * {@link #DEFAULT_SECTION_LENGTH} and {@link #getDefaultSectionGap()}. + * + * @param label the label for the section + * @return the created section + */ + public Section nextSection(String label) { + return nextSection(label, DEFAULT_SECTION_LENGTH, defaultSectionGap); + } + + /** + * Creates and adds a new {@link Section} to this axis with the specified label, length and + * {@link #getDefaultSectionGap()}. + * + * @param label the label for the section + * @param length the length of the section on this axis + * @return the created section + */ + public Section nextSection(String label, double length) { + return nextSection(label, length, defaultSectionGap); + } + + /** + * Creates and adds a new {@link Section} to this axis with the specified label, length and gap. + * + * @param label the label for the section + * @param length the length of the section on this axis (must be greater than zero) + * @param gap the gap between the section and the previous section on this axis (must be 0.0 or higher) + * @return the created section + */ + public Section nextSection(String label, double length, double gap) { + Args.requireGreaterThanZero(length, "length"); + Args.requireNonNegative(gap, "gap"); + double sectionLowerBound = 0; + if (!sections.isEmpty()) { + sectionLowerBound = sections.getLast().getRange().getUpperBound() + gap; + } + Section section = new Section(this, new Range(sectionLowerBound, sectionLowerBound + length), label); + sections.add(section); + return section; + } + + /** + * Receives notification of a section change. + * + * @param section the section. + */ + protected void sectionChanged(Section section) { + fireChangeEvent(); + } + + @Override + public double valueToJava2D(double value, Rectangle2D area, RectangleEdge edge) { + Range range = getRange(); + double axisMin = range.getLowerBound(); + double axisMax = range.getUpperBound(); + + double min = 0.0; + double max = 0.0; + if (RectangleEdge.isTopOrBottom(edge)) { + min = area.getX(); + max = area.getMaxX(); + } else if (RectangleEdge.isLeftOrRight(edge)) { + max = area.getMinY(); + min = area.getMaxY(); + } + if (isInverted()) { + return max - ((value - axisMin) / (axisMax - axisMin)) * (max - min); + } else { + return min + ((value - axisMin) / (axisMax - axisMin)) * (max - min); + } + } + + @Override + public double java2DToValue(double java2dValue, Rectangle2D area, RectangleEdge edge) { + Range range = getRange(); + double axisMin = range.getLowerBound(); + double axisMax = range.getUpperBound(); + + double min = 0.0; + double max = 0.0; + if (RectangleEdge.isTopOrBottom(edge)) { + min = area.getX(); + max = area.getMaxX(); + } else if (RectangleEdge.isLeftOrRight(edge)) { + min = area.getMaxY(); + max = area.getY(); + } + if (isInverted()) { + return axisMax - (java2dValue - min) / (max - min) * (axisMax - axisMin); + } else { + return axisMin + (java2dValue - min) / (max - min) * (axisMax - axisMin); + } + } + + @Override + public void configure() { + if (isAutoRange()) { + autoAdjustRange(); + } + } + + @Override + public Range calculateAutoRange(boolean adhereToMax) { + // no plot, no data + if (getPlot() instanceof ValueAxisPlot) { + // ensure that all the sections are displayed + double lower; + double upper; + if (sections.isEmpty()) { + Range r = getDefaultAutoRange(); + lower = r.getLowerBound(); + upper = r.getUpperBound(); + } else { + lower = sections.getFirst().getRange().getLowerBound(); + upper = sections.getLast().getRange().getUpperBound(); + } + + double fixedAutoRange = getFixedAutoRange(); + if (adhereToMax && fixedAutoRange > 0.0) { + Range aligned = getAutoRangeAlign().align(new Range(lower, upper), fixedAutoRange); + lower = aligned.getLowerBound(); + upper = aligned.getUpperBound(); + } else { + double range = upper - lower; + // ensure the auto-range is at least in size... + double minRange = getAutoRangeMinimumSize(); + if (range < minRange) { + upper = (upper + lower + minRange) / 2; + lower = (upper + lower - minRange) / 2; + } + + // Add the margins + upper += upper * getUpperMargin(); + lower -= lower * getLowerMargin(); + } + + return new Range(lower, upper); + } + return null; + } + + @Override + public AxisState draw(Graphics2D g2, double cursor, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge, + PlotRenderingInfo plotState) + { + // draw the tick marks and labels... + AxisState state = drawTickMarksAndLabels(g2, cursor, plotArea, dataArea, edge); + + if (this.gridBandsVisible) { + drawGridBands(g2, plotArea, dataArea, edge); + } + + if (getAttributedLabel() != null) { + state = drawAttributedLabel(getAttributedLabel(), g2, plotArea, dataArea, edge, state); + } else { + state = drawLabel(getLabel(), g2, plotArea, dataArea, edge, state); + } + createAndAddEntity(cursor, state, dataArea, edge, plotState); + createTickLabelEntities(g2, cursor, state, dataArea, edge, plotState); + + return state; + } + + /** + * Creates the {@link TickLabelEntity}s for this axis. + * + * @param g2 the graphics device ({@code null} not permitted). + * @param cursor the initial cursor value. + * @param state the axis state after completion of the drawing with a possibly updated cursor position. + * @param dataArea the data area. + * @param edge the edge ({@code null} not permitted). + * @param plotState the PlotRenderingInfo from which a reference to the entity collection can be obtained. + */ + protected void createTickLabelEntities(Graphics2D g2, double cursor, AxisState state, Rectangle2D dataArea, + RectangleEdge edge, PlotRenderingInfo plotState) + { + if (plotState == null || plotState.getOwner() == null || plotState.getOwner().getEntityCollection() == null) { + return; // no need to create entity if we can't save it anyways... + } + EntityCollection entityCollection = plotState.getOwner().getEntityCollection(); + for (Object tick: state.getTicks()) { + if (tick instanceof SectionTick && ((SectionTick)tick).getTooltipText() != null) { + Shape tickTextBounds = calculateTickTextBounds((SectionTick)tick, g2, cursor, dataArea, edge); + entityCollection.add(new TickLabelEntity(tickTextBounds, ((SectionTick)tick).getTooltipText(), null)); + } + } + } + + /** + * Draws the grid bands. Alternate bands are colored using gridBandPaint + * (DEFAULT_GRID_BAND_PAINT by default). + * + * @param g2 the graphics target (null not permitted). + * @param plotArea the area within which the plot is drawn (null not permitted). + * @param dataArea the data area to which the axes are aligned (null not permitted). + * @param edge the edge to which the axis is aligned (null not permitted). + */ + protected void drawGridBands(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, RectangleEdge edge) { + Shape savedClip = g2.getClip(); + g2.clip(dataArea); + if (RectangleEdge.isTopOrBottom(edge)) { + drawGridBandsHorizontal(g2, plotArea, dataArea, edge); + } else if (RectangleEdge.isLeftOrRight(edge)) { + drawGridBandsVertical(g2, plotArea, dataArea, edge); + } + g2.setClip(savedClip); + } + + /** + * Draws the grid bands for the axis when it is at the top or bottom of the plot. + * + * @param g2 the graphics target (null not permitted). + * @param plotArea the area within which the plot is drawn (not used here). + * @param dataArea the area for the data (to which the axes are aligned, null not permitted). + * @param edge the edge to which the axis is aligned (null not permitted). + */ + protected void drawGridBandsHorizontal(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, + RectangleEdge edge) + { + throw new UnsupportedOperationException("This axis does not support horizontal plotting yet!"); + } + + /** + * Draws the grid bands for an axis that is aligned to the left or right of the data area (that is, a vertical + * axis). + * + * @param g2 the graphics target (null not permitted). + * @param plotArea the area within which the plot is drawn (not used here). + * @param dataArea the area for the data (to which the axes are aligned, null not permitted). + * @param firstGridBandIsDark True: the first grid band takes the color of gridBandPaint. False: the + * second grid band takes the color of gridBandPaint. + * @param ticks a list of ticks (null not permitted). + */ + protected void drawGridBandsVertical(Graphics2D g2, Rectangle2D plotArea, Rectangle2D dataArea, + RectangleEdge edge) + { + boolean useAlternatePaint = true; + double xx = dataArea.getX(); + double yMax, yMin; + + // gets the outline stroke width of the plot + double outlineStrokeWidth = 1.0; + Stroke outlineStroke = getPlot().getOutlineStroke(); + if (outlineStroke != null && outlineStroke instanceof BasicStroke) { + outlineStrokeWidth = ((BasicStroke)outlineStroke).getLineWidth(); + } + + for (Section section: sections) { + if (!getRange().intersects(section.getRange())) { + continue; + } + + yMin = valueToJava2D(section.getRange().getLowerBound(), dataArea, RectangleEdge.LEFT); + yMax = valueToJava2D(section.getRange().getUpperBound(), dataArea, RectangleEdge.LEFT); + + g2.setPaint(useAlternatePaint ? getGridBandAlternatePaint(section) : getGridBandPaint(section)); + useAlternatePaint = !useAlternatePaint; + + Rectangle2D band = new Rectangle2D.Double(xx + outlineStrokeWidth, Math.min(yMin, yMax), + dataArea.getMaxX() - xx - outlineStrokeWidth, Math.abs(yMax - yMin)); + g2.fill(band); + } + } + + @Override + public List refreshTicks(Graphics2D g2, AxisState state, Rectangle2D dataArea, RectangleEdge edge) { + if (RectangleEdge.isTopOrBottom(edge)) { + return refreshTicksHorizontal(g2, dataArea, edge); + } else if (RectangleEdge.isLeftOrRight(edge)) { + return refreshTicksVertical(g2, dataArea, edge); + } else { + return Collections.emptyList(); + } + } + + /** + * Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for + * drawing). This method is called when the axis is at the top or bottom of the chart (so the axis is "horizontal"). + * + * @param g2 the graphics device. + * @param dataArea the area in which the plot should be drawn. + * @param edge the location of the axis. + * + * @return The ticks. + */ + protected List refreshTicksHorizontal(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { + throw new UnsupportedOperationException("This axis does not support horizontal plotting yet!"); + } + + /** + * Calculates the positions of the tick labels for the axis, storing the results in the tick label list (ready for + * drawing). This method is called when the axis is at the left or right of the chart (so the axis is "vertical"). + * + * @param g2 the graphics device. + * @param dataArea the area in which the plot should be drawn. + * @param edge the location of the axis. + * + * @return The ticks. + */ + protected List refreshTicksVertical(Graphics2D g2, Rectangle2D dataArea, RectangleEdge edge) { + Font tickLabelFont = getTickLabelFont(); + g2.setFont(tickLabelFont); + + double cursor = 0.0; + TextAnchor textAnchor; + TextAnchor rotationAnchor; + double angle; + if (isVerticalTickLabels()) { + if (edge == RectangleEdge.LEFT) { + textAnchor = TextAnchor.BOTTOM_CENTER; + rotationAnchor = TextAnchor.BOTTOM_CENTER; + angle = -Math.PI / 2.0; + } else { + textAnchor = TextAnchor.BOTTOM_CENTER; + rotationAnchor = TextAnchor.BOTTOM_CENTER; + angle = Math.PI / 2.0; + } + } else { + if (edge == RectangleEdge.LEFT) { + textAnchor = TextAnchor.CENTER_RIGHT; + rotationAnchor = TextAnchor.CENTER_RIGHT; + angle = 0.0; + } else { + textAnchor = TextAnchor.CENTER_LEFT; + rotationAnchor = TextAnchor.CENTER_LEFT; + angle = 0.0; + } + } + + // Creating the ticks and check if labels do not overlap + List ticks = new ArrayList<>(); + Area ticksTextArea = new Area(); + + for (Section section: sections) { + if (!getRange().contains(section.getRange().getCentralValue())) { + continue; + } + SectionTick sectionTick = createSectionTick(TickType.MINOR, section.getRange().getCentralValue(), + section.getLabel(), textAnchor, rotationAnchor, angle); + // Avoid to draw overlapping ticks labels + Shape tickTextBounds = calculateTickTextBounds(sectionTick, g2, cursor, dataArea, edge); + if (!intersect(ticksTextArea, tickTextBounds)) { + ticksTextArea.add(new Area(tickTextBounds)); + ticks.add(sectionTick); + } + } + + for (Section section: sections) { + ValueAxis gridBandAxis = section.getGridBandAxis(); + if (null == gridBandAxis) { + continue; + } + + Range sectionRange = section.getRange(); + double yLower = valueToJava2D(sectionRange.getLowerBound(), dataArea, edge); + double yUpper = valueToJava2D(sectionRange.getUpperBound(), dataArea, edge); + // Calculate ticks for the scaled data area + Rectangle2D sectionDataArea = new Rectangle2D.Double(dataArea.getX(), yLower, dataArea.getWidth(), + Math.abs(yUpper - yLower)); Range gridBandRange = gridBandAxis.getRange(); - List sectionTicks = gridBandAxis.refreshTicks(g2, new AxisState(cursor), sectionDataArea, edge); - for (Object tick : sectionTicks) { - ValueTick sectionTick = (ValueTick) tick; - // Scale the ticks back to the original data area - double scaledValue = AxisUtils.scaleValue(sectionTick.getValue(), gridBandRange, sectionRange); - if (!getRange().contains(scaledValue)) { - continue; - } - SectionTick scaledTick = createSectionTick(sectionTick.getTickType(), scaledValue, - sectionTick.getText(), sectionTick.getTextAnchor(), sectionTick.getRotationAnchor(), - sectionTick.getAngle()); - - // Avoid to draw overlapping ticks labels - Shape tickTextBounds = calculateTickTextBounds(scaledTick, g2, cursor, dataArea, edge); - if (intersect(ticksTextArea, tickTextBounds)) { - // Just add the tick, but without label - ticks.add(createSectionTick(sectionTick.getTickType(), scaledValue, null, - sectionTick.getTextAnchor(), sectionTick.getRotationAnchor(), sectionTick.getAngle())); - } else { - ticksTextArea.add(new Area(tickTextBounds)); - ticks.add(scaledTick); - } - } - } - return ticks; - } - - private SectionTick createSectionTick(TickType tickType, double value, String label, TextAnchor textAnchor, - TextAnchor rotationAnchor, double angle) { - final String tickLabel = createTickLabel(label); - final SectionTick sectionTick = new SectionTick(tickType, value, tickLabel, textAnchor, rotationAnchor, angle); - - switch (getTooltipMode()) { - case MAX_EXCEEDED: - if (Objects.equals(label, tickLabel)) { - // No need to add tooltip - break; - } - case ALWAYS: - sectionTick.setTooltipText(label); - break; - default: - // Nothing to do - break; - } - - return sectionTick; - } - - private Shape calculateTickTextBounds(ValueTick tick, Graphics2D g2, double cursor, Rectangle2D dataArea, - RectangleEdge edge) { - String tickText = tick.getText(); - if (null == tickText || tickText.isEmpty()) { - return new Area(); - } - - Font tickLabelFont = getTickLabelFont(); - g2.setFont(tickLabelFont); - - float[] anchorPoint = calculateAnchorPoint(tick, cursor, dataArea, edge); - return TextUtils.calculateRotatedStringBounds(tickText, g2, anchorPoint[0], anchorPoint[1], - tick.getTextAnchor(), tick.getAngle(), tick.getRotationAnchor()); - } - - private boolean intersect(Shape a, Shape b) { - final Area areaA = new Area(a); - final Area areaB = new Area(b); - areaA.intersect(areaB); - return !areaA.isEmpty(); - } + List sectionTicks = gridBandAxis.refreshTicks(g2, new AxisState(cursor), sectionDataArea, edge); + for (Object tick: sectionTicks) { + ValueTick sectionTick = (ValueTick)tick; + // Scale the ticks back to the original data area + double scaledValue = AxisUtils.scaleValue(sectionTick.getValue(), gridBandRange, sectionRange); + if (!getRange().contains(scaledValue)) { + continue; + } + SectionTick scaledTick = createSectionTick(sectionTick.getTickType(), scaledValue, + sectionTick.getText(), sectionTick.getTextAnchor(), sectionTick.getRotationAnchor(), + sectionTick.getAngle()); + + // Avoid to draw overlapping ticks labels + Shape tickTextBounds = calculateTickTextBounds(scaledTick, g2, cursor, dataArea, edge); + if (intersect(ticksTextArea, tickTextBounds)) { + // Just add the tick, but without label + ticks.add(createSectionTick(sectionTick.getTickType(), scaledValue, null, + sectionTick.getTextAnchor(), sectionTick.getRotationAnchor(), sectionTick.getAngle())); + } else { + ticksTextArea.add(new Area(tickTextBounds)); + ticks.add(scaledTick); + } + } + } + return ticks; + } + + private SectionTick createSectionTick(TickType tickType, double value, String label, TextAnchor textAnchor, + TextAnchor rotationAnchor, double angle) + { + final String tickLabel = createTickLabel(label); + final SectionTick sectionTick = new SectionTick(tickType, value, tickLabel, textAnchor, rotationAnchor, angle); + + switch (getTooltipMode()) { + case MAX_EXCEEDED: + if (Objects.equals(label, tickLabel)) { + // No need to add tooltip + break; + } + case ALWAYS: + sectionTick.setTooltipText(label); + break; + default: + // Nothing to do + break; + } + + return sectionTick; + } + + private Shape calculateTickTextBounds(ValueTick tick, Graphics2D g2, double cursor, Rectangle2D dataArea, + RectangleEdge edge) + { + String tickText = tick.getText(); + if (null == tickText || tickText.isEmpty()) { + return new Area(); + } + + Font tickLabelFont = getTickLabelFont(); + g2.setFont(tickLabelFont); + + float[] anchorPoint = calculateAnchorPoint(tick, cursor, dataArea, edge); + return TextUtils.calculateRotatedStringBounds(tickText, g2, anchorPoint[0], anchorPoint[1], + tick.getTextAnchor(), tick.getAngle(), tick.getRotationAnchor()); + } + + private boolean intersect(Shape a, Shape b) { + final Area areaA = new Area(a); + final Area areaB = new Area(b); + areaA.intersect(areaB); + return !areaA.isEmpty(); + } } diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/axis/SectionTick.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/axis/SectionTick.java index d51dcefa9d7bff581b2c8d5494bd35158811249f..476598b4343670331e29a449e0356e0fb4358bff 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/axis/SectionTick.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/axis/SectionTick.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.chart.axis; import org.jfree.chart.axis.TickType; @@ -17,47 +18,46 @@ import org.jfree.chart.ui.TextAnchor; * A labeled tick with the option for tooltip text. */ public class SectionTick extends ValueTick { - private static final long serialVersionUID = 4133486505758570577L; + private static final long serialVersionUID = 4133486505758570577L; - private String tooltipText; + private String tooltipText; - /** - * Creates a new tick. - * - * @param tickType the tick type. - * @param value the value. - * @param label the label. - * @param textAnchor the part of the label that is aligned with the anchor - * point. - * @param rotationAnchor defines the rotation point relative to the text. - * @param angle the rotation angle (in radians). - */ - public SectionTick(TickType tickType, double value, String label, TextAnchor textAnchor, TextAnchor rotationAnchor, - double angle) { - super(tickType, value, label, textAnchor, rotationAnchor, angle); - } + /** + * Creates a new tick. + * + * @param tickType the tick type. + * @param value the value. + * @param label the label. + * @param textAnchor the part of the label that is aligned with the anchor point. + * @param rotationAnchor defines the rotation point relative to the text. + * @param angle the rotation angle (in radians). + */ + public SectionTick(TickType tickType, double value, String label, TextAnchor textAnchor, TextAnchor rotationAnchor, + double angle) + { + super(tickType, value, label, textAnchor, rotationAnchor, angle); + } - /** - * Returns the tool tip text for the tick. This will be displayed in a - * {@link org.jfree.chart.ChartPanel} when the mouse pointer hovers over the - * tick. - * - * @return The tool tip text (possibly {@code null}). - * - * @see #setToolTipText(String) - */ - public String getTooltipText() { - return tooltipText; - } + /** + * Returns the tool tip text for the tick. This will be displayed in a {@link org.jfree.chart.ChartPanel} when the + * mouse pointer hovers over the tick. + * + * @return The tool tip text (possibly {@code null}). + * + * @see #setToolTipText(String) + */ + public String getTooltipText() { + return tooltipText; + } - /** - * Sets the tool tip text for the tick. - * - * @param text the tool tip text ({@code null} permitted). - * - * @see #getToolTipText() - */ - public void setTooltipText(String tooltipText) { - this.tooltipText = tooltipText; - } -} \ No newline at end of file + /** + * Sets the tool tip text for the tick. + * + * @param text the tool tip text ({@code null} permitted). + * + * @see #getToolTipText() + */ + public void setTooltipText(String tooltipText) { + this.tooltipText = tooltipText; + } +} diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/geom/Arrow2D.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/geom/Arrow2D.java index bdeabde5975544b175e8d0d5ba43de3555ce6e25..24eba9c420e5fc2e4966074bcaef29adc160d499 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/geom/Arrow2D.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/geom/Arrow2D.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.chart.geom; import java.awt.Rectangle; @@ -21,79 +22,78 @@ import java.awt.geom.Rectangle2D; * A pointy arrow shape. */ public abstract class Arrow2D implements Shape { - protected final Path2D arrow; + protected final Path2D arrow; - protected Arrow2D(Path2D arrow) { - this.arrow = arrow; - } + protected Arrow2D(Path2D arrow) { + this.arrow = arrow; + } - /** - * An arrow with double precision and center anchor. - */ - public static class Double extends Arrow2D { - /** - * Creates an instance of {@link Arrow2D} with {@link java.lang.Double double} - * precision.
- * Using a positive width value creates a right pointing arrow and - * a negative width value creates a left pointing arrow. - */ - public Double(double x, double y, double width, double height) { - super(new Path2D.Double()); - arrow.moveTo(x + width, y + (height / 2)); - arrow.lineTo(x, y + height); - arrow.lineTo(x + (width / 2), y + (height / 2)); - arrow.lineTo(x, y); - arrow.closePath(); - } - } + /** + * An arrow with double precision and center anchor. + */ + public static class Double extends Arrow2D { + /** + * Creates an instance of {@link Arrow2D} with {@link java.lang.Double double} precision.
+ * Using a positive width value creates a right pointing arrow and a negative width + * value creates a left pointing arrow. + */ + public Double(double x, double y, double width, double height) { + super(new Path2D.Double()); + arrow.moveTo(x + width, y + (height / 2)); + arrow.lineTo(x, y + height); + arrow.lineTo(x + (width / 2), y + (height / 2)); + arrow.lineTo(x, y); + arrow.closePath(); + } + } - @Override - public Rectangle2D getBounds2D() { - return arrow.getBounds2D(); - } + @Override + public Rectangle2D getBounds2D() { + return arrow.getBounds2D(); + } - @Override - public final Rectangle getBounds() { - return arrow.getBounds(); - } + @Override + public final Rectangle getBounds() { + return arrow.getBounds(); + } - @Override - public final boolean contains(double x, double y) { - return arrow.contains(x, y); - } + @Override + public final boolean contains(double x, double y) { + return arrow.contains(x, y); + } - @Override - public final boolean contains(Point2D p) { - return arrow.contains(p); - } + @Override + public final boolean contains(Point2D p) { + return arrow.contains(p); + } - @Override - public final boolean contains(double x, double y, double w, double h) { - return arrow.contains(x, y, w, h); - } + @Override + public final boolean contains(double x, double y, double w, double h) { + return arrow.contains(x, y, w, h); + } - @Override - public final boolean contains(Rectangle2D r) { - return arrow.contains(r); - } + @Override + public final boolean contains(Rectangle2D r) { + return arrow.contains(r); + } - @Override - public final boolean intersects(double x, double y, double w, double h) { - return arrow.intersects(x, y, w, h); - } + @Override + public final boolean intersects(double x, double y, double w, double h) { + return arrow.intersects(x, y, w, h); + } - @Override - public final boolean intersects(Rectangle2D r) { - return arrow.intersects(r); - } + @Override + public final boolean intersects(Rectangle2D r) { + return arrow.intersects(r); + } - @Override - public PathIterator getPathIterator(AffineTransform at) { - return arrow.getPathIterator(at); - } + @Override + public PathIterator getPathIterator(AffineTransform at) { + return arrow.getPathIterator(at); + } - @Override - public final PathIterator getPathIterator(AffineTransform at, double flatness) { - return arrow.getPathIterator(at, flatness); - } + @Override + public final PathIterator getPathIterator(AffineTransform at, double flatness) { + return arrow.getPathIterator(at, flatness); + } } diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/geom/Triangle2D.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/geom/Triangle2D.java index 392250917915196fa5bbe5e2575a2e2aff5e7bc9..829993b8e6026e7dc082f17ccc0fa2f21ad84c23 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/geom/Triangle2D.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/geom/Triangle2D.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.chart.geom; import java.awt.Rectangle; @@ -21,69 +22,69 @@ import java.awt.geom.Rectangle2D; * A triangle shape. */ public abstract class Triangle2D implements Shape { - protected final Path2D arrow; - - protected Triangle2D(Path2D triangle) { - this.arrow = triangle; - } - - public static class Double extends Triangle2D { - public Double(double xA, double yA, double xB, double yB, double xC, double yC) { - super(new Path2D.Double()); - arrow.moveTo(xA, yA); - arrow.lineTo(xB, yB); - arrow.lineTo(xC, yC); - arrow.closePath(); - } - } + protected final Path2D arrow; + + protected Triangle2D(Path2D triangle) { + this.arrow = triangle; + } + + public static class Double extends Triangle2D { + public Double(double xA, double yA, double xB, double yB, double xC, double yC) { + super(new Path2D.Double()); + arrow.moveTo(xA, yA); + arrow.lineTo(xB, yB); + arrow.lineTo(xC, yC); + arrow.closePath(); + } + } - @Override - public Rectangle2D getBounds2D() { - return arrow.getBounds2D(); - } + @Override + public Rectangle2D getBounds2D() { + return arrow.getBounds2D(); + } - @Override - public final Rectangle getBounds() { - return arrow.getBounds(); - } + @Override + public final Rectangle getBounds() { + return arrow.getBounds(); + } - @Override - public final boolean contains(double x, double y) { - return arrow.contains(x, y); - } + @Override + public final boolean contains(double x, double y) { + return arrow.contains(x, y); + } - @Override - public final boolean contains(Point2D p) { - return arrow.contains(p); - } + @Override + public final boolean contains(Point2D p) { + return arrow.contains(p); + } - @Override - public final boolean contains(double x, double y, double w, double h) { - return arrow.contains(x, y, w, h); - } + @Override + public final boolean contains(double x, double y, double w, double h) { + return arrow.contains(x, y, w, h); + } - @Override - public final boolean contains(Rectangle2D r) { - return arrow.contains(r); - } + @Override + public final boolean contains(Rectangle2D r) { + return arrow.contains(r); + } - @Override - public final boolean intersects(double x, double y, double w, double h) { - return arrow.intersects(x, y, w, h); - } + @Override + public final boolean intersects(double x, double y, double w, double h) { + return arrow.intersects(x, y, w, h); + } - @Override - public final boolean intersects(Rectangle2D r) { - return arrow.intersects(r); - } + @Override + public final boolean intersects(Rectangle2D r) { + return arrow.intersects(r); + } - @Override - public PathIterator getPathIterator(AffineTransform at) { - return arrow.getPathIterator(at); - } + @Override + public PathIterator getPathIterator(AffineTransform at) { + return arrow.getPathIterator(at); + } - @Override - public final PathIterator getPathIterator(AffineTransform at, double flatness) { - return arrow.getPathIterator(at, flatness); - } + @Override + public final PathIterator getPathIterator(AffineTransform at, double flatness) { + return arrow.getPathIterator(at, flatness); + } } diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/plot/PlotUtils.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/plot/PlotUtils.java index 0056fc97c6bb756a13afa6511847de90bd57fdf1..929afb8da6d823a9c39c31de9a814ee1f94ace90 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/plot/PlotUtils.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/plot/PlotUtils.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.chart.plot; import org.jfree.chart.plot.XYPlot; @@ -16,19 +17,27 @@ import org.jfree.data.xy.XYDataset; * Some utility methods related to the plot classes. */ public class PlotUtils { - /** - * Returns the cumulative amount of items for all datasets in the plot. - * - * @return the cumulative amount of items for all datasets in the plot. - */ - public static int getItemCount(XYPlot plot) { - int itemCount = 0; - for (int d = 0; d < plot.getDatasetCount(); d++) { - XYDataset dataset = plot.getDataset(d); - for (int s = 0; s < dataset.getSeriesCount(); s++) { - itemCount += dataset.getItemCount(s); - } - } - return itemCount; - } -} \ No newline at end of file + + /** + * Private constructor prevents object creation. + */ + private PlotUtils() { + // Empty for utility classes + } + + /** + * Returns the cumulative amount of items for all datasets in the plot. + * + * @return the cumulative amount of items for all datasets in the plot. + */ + public static int getItemCount(XYPlot plot) { + int itemCount = 0; + for (int d = 0; d < plot.getDatasetCount(); d++) { + XYDataset dataset = plot.getDataset(d); + for (int s = 0; s < dataset.getSeriesCount(); s++) { + itemCount += dataset.getItemCount(s); + } + } + return itemCount; + } +} diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/renderer/xy/XYEdgeRenderer.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/renderer/xy/XYEdgeRenderer.java index 8ee05c67e4367082e4937b061b55966bcfff22b6..2c1402c19e293852ab5d48885f1e78a0c7434aa9 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/renderer/xy/XYEdgeRenderer.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/renderer/xy/XYEdgeRenderer.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.chart.renderer.xy; import java.awt.Graphics2D; @@ -37,325 +38,335 @@ import org.jfree.data.xy.IntervalXYDataset; import org.jfree.data.xy.XYDataset; /** - * Renders edges (i.e. lines) on an {@link XYPlot}, requires an - * {@link IntervalXYDataset}. Lines can be configured to have begin and/or end - * shapes, e.g. an {@link Arrow2D}. + * Renders edges (i.e. lines) on an {@link XYPlot}, requires an {@link IntervalXYDataset}. Lines can be configured to + * have begin and/or end shapes, e.g. an {@link Arrow2D}. */ public class XYEdgeRenderer extends AbstractXYItemRenderer implements XYItemRenderer { - private static final long serialVersionUID = -754074656456575380L; - - public static final boolean DEFAULT_SHAPE_ROTATE = true; - - public static final boolean DEFAULT_DRAW_PLOT_CROSSING_LINES = true; - - private final ShapeList beginShapes = new ShapeList(); - private final BooleanList beginShapesRotate = new BooleanList(); - private final ShapeList endShapes = new ShapeList(); - private final BooleanList endShapesRotate = new BooleanList(); - private final BooleanList drawPlotCrossingLines = new BooleanList(); - - private Shape defaultBeginShape; - private Boolean defaultBeginShapeRotate; - private Shape defaultEndShape; - private Boolean defaultEndShapeRotate; - private boolean defaultShapeRotate; - private boolean defaultDrawPlotCrossingLines; - - public XYEdgeRenderer() { - this.defaultShapeRotate = DEFAULT_SHAPE_ROTATE; - this.defaultDrawPlotCrossingLines = DEFAULT_DRAW_PLOT_CROSSING_LINES; - setDefaultShape(new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0)); - setAutoPopulateSeriesShape(false); - } - - public void setDefaultDrawPlotCrossingLines(boolean drawCrossingLines, boolean notify) { - this.defaultDrawPlotCrossingLines = drawCrossingLines; - if (notify) { - fireChangeEvent(); - } - } - - /** - * @return true to render lines which start and end outside, but cross the visible area of the plot - */ - public boolean getDefaultDrawPlotCrossingLines() { - return this.defaultDrawPlotCrossingLines; - } - - /** - * @see #getDefaultDrawPlotCrossingLines() - */ - public boolean getSeriesDrawPlotCrossingLines(int series) { - Boolean drawCrossingLines = this.drawPlotCrossingLines.getBoolean(series); - return null == drawCrossingLines ? getDefaultDrawPlotCrossingLines() : drawCrossingLines; - } - - public void setSeriesDrawPlotCrossingLines(int series, boolean drawCrossingLines, boolean notify) { - this.drawPlotCrossingLines.setBoolean(series, drawCrossingLines); - if (notify) { - fireChangeEvent(); - } - } - - public void setDefaultShapeRotate(boolean baseShapeRotate) { - this.defaultShapeRotate = baseShapeRotate; - } - - public boolean getDefaultShapeRotate(boolean baseShapeRotate) { - return this.defaultShapeRotate; - } - - public void setDefaultBeginShape(Shape baseBeginShape, boolean notify) { - this.defaultBeginShape = baseBeginShape; - if (notify) { - fireChangeEvent(); - } - } - - public Shape getDefaultBeginShape() { - return defaultBeginShape; - } - - public void setSeriesBeginShape(int series, Shape shape, boolean notify) { - this.beginShapes.setShape(series, shape); - if (notify) { - fireChangeEvent(); - } - } - - public Shape getSeriesBeginShape(int series) { - Shape shape = this.beginShapes.getShape(series); - return null == shape ? this.defaultBeginShape : shape; - } - - public void setSeriesBeginShapeRotate(int series, boolean rotate, boolean notify) { - this.beginShapesRotate.setBoolean(series, rotate); - if (notify) { - fireChangeEvent(); - } - } - - public void setDefaultBeginShapeRotate(Boolean baseBeginShapeRotate, boolean notify) { - this.defaultBeginShapeRotate = baseBeginShapeRotate; - if (notify) { - fireChangeEvent(); - } - } - - public Boolean getDefaultBeginShapeRotate() { - return null == this.defaultBeginShapeRotate ? this.defaultShapeRotate : this.defaultBeginShapeRotate; - } - - public boolean getSeriesBeginShapeRotate(int series) { - Boolean rotate = this.beginShapesRotate.getBoolean(series); - return null == rotate ? getDefaultBeginShapeRotate() : rotate; - } - - public void setDefaultEndShape(Shape baseEndShape, boolean notify) { - this.defaultEndShape = baseEndShape; - if (notify) { - fireChangeEvent(); - } - } - - public Shape getDefaultEndShape() { - return defaultEndShape; - } - - public void setSeriesEndShape(int series, Shape shape, boolean notify) { - this.endShapes.setShape(series, shape); - if (notify) { - fireChangeEvent(); - } - } - - public Shape getSeriesEndShape(int series) { - Shape shape = this.endShapes.getShape(series); - return null == shape ? this.defaultEndShape : shape; - } - - public void setDefaultEndShapeRotate(Boolean baseEndShapeRotate, boolean notify) { - this.defaultEndShapeRotate = baseEndShapeRotate; - if (notify) { - fireChangeEvent(); - } - } - - public Boolean getDefaultEndShapeRotate() { - return null == this.defaultEndShapeRotate ? this.defaultShapeRotate : this.defaultEndShapeRotate; - } - - public void setSeriesEndShapeRotate(int series, boolean rotate, boolean notify) { - this.endShapesRotate.setBoolean(series, rotate); - if (notify) { - fireChangeEvent(); - } - } - - public boolean getSeriesEndShapeRotate(int series) { - Boolean rotate = this.endShapesRotate.getBoolean(series); - return null == rotate ? getDefaultEndShapeRotate() : rotate; - } - - @Override - public LegendItem getLegendItem(int datasetIndex, int series) { - LegendItem item = super.getLegendItem(datasetIndex, series); - item.setShape(lookupLegendShape(series)); - return item; - } - - @Override - public Shape lookupSeriesShape(int series) { - Shape shape = getSeriesEndShape(series); - if (null == shape) { - shape = getSeriesBeginShape(series); - } - if (null == shape) { - shape = super.lookupSeriesShape(series); - } - return shape; - } - - @Override - public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset data, - PlotRenderingInfo info) { - XYItemRendererState state = super.initialise(g2, dataArea, plot, data, info); - // disable visible items optimization - it doesn't work for this renderer... - state.setProcessVisibleItemsOnly(false); - return state; - } - - @Override - public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, - XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, - CrosshairState crosshairState, int pass) { - if (!getItemVisible(series, item) || ! (dataset instanceof IntervalXYDataset)) { + private static final long serialVersionUID = -754074656456575380L; + + public static final boolean DEFAULT_SHAPE_ROTATE = true; + + public static final boolean DEFAULT_DRAW_PLOT_CROSSING_LINES = true; + + private final ShapeList beginShapes = new ShapeList(); + + private final BooleanList beginShapesRotate = new BooleanList(); + + private final ShapeList endShapes = new ShapeList(); + + private final BooleanList endShapesRotate = new BooleanList(); + + private final BooleanList drawPlotCrossingLines = new BooleanList(); + + private Shape defaultBeginShape; + + private Boolean defaultBeginShapeRotate; + + private Shape defaultEndShape; + + private Boolean defaultEndShapeRotate; + + private boolean defaultShapeRotate; + + private boolean defaultDrawPlotCrossingLines; + + public XYEdgeRenderer() { + this.defaultShapeRotate = DEFAULT_SHAPE_ROTATE; + this.defaultDrawPlotCrossingLines = DEFAULT_DRAW_PLOT_CROSSING_LINES; + setDefaultShape(new Rectangle2D.Double(-4.0, -4.0, 8.0, 8.0)); + setAutoPopulateSeriesShape(false); + } + + public void setDefaultDrawPlotCrossingLines(boolean drawCrossingLines, boolean notify) { + this.defaultDrawPlotCrossingLines = drawCrossingLines; + if (notify) { + fireChangeEvent(); + } + } + + /** + * @return true to render lines which start and end outside, but cross the visible area of the plot + */ + public boolean getDefaultDrawPlotCrossingLines() { + return this.defaultDrawPlotCrossingLines; + } + + /** + * @see #getDefaultDrawPlotCrossingLines() + */ + public boolean getSeriesDrawPlotCrossingLines(int series) { + Boolean drawCrossingLines = this.drawPlotCrossingLines.getBoolean(series); + return null == drawCrossingLines ? getDefaultDrawPlotCrossingLines() : drawCrossingLines; + } + + public void setSeriesDrawPlotCrossingLines(int series, boolean drawCrossingLines, boolean notify) { + this.drawPlotCrossingLines.setBoolean(series, drawCrossingLines); + if (notify) { + fireChangeEvent(); + } + } + + public void setDefaultShapeRotate(boolean baseShapeRotate) { + this.defaultShapeRotate = baseShapeRotate; + } + + public boolean getDefaultShapeRotate(boolean baseShapeRotate) { + return this.defaultShapeRotate; + } + + public void setDefaultBeginShape(Shape baseBeginShape, boolean notify) { + this.defaultBeginShape = baseBeginShape; + if (notify) { + fireChangeEvent(); + } + } + + public Shape getDefaultBeginShape() { + return defaultBeginShape; + } + + public void setSeriesBeginShape(int series, Shape shape, boolean notify) { + this.beginShapes.setShape(series, shape); + if (notify) { + fireChangeEvent(); + } + } + + public Shape getSeriesBeginShape(int series) { + Shape shape = this.beginShapes.getShape(series); + return null == shape ? this.defaultBeginShape : shape; + } + + public void setSeriesBeginShapeRotate(int series, boolean rotate, boolean notify) { + this.beginShapesRotate.setBoolean(series, rotate); + if (notify) { + fireChangeEvent(); + } + } + + public void setDefaultBeginShapeRotate(Boolean baseBeginShapeRotate, boolean notify) { + this.defaultBeginShapeRotate = baseBeginShapeRotate; + if (notify) { + fireChangeEvent(); + } + } + + public Boolean getDefaultBeginShapeRotate() { + return null == this.defaultBeginShapeRotate ? this.defaultShapeRotate : this.defaultBeginShapeRotate; + } + + public boolean getSeriesBeginShapeRotate(int series) { + Boolean rotate = this.beginShapesRotate.getBoolean(series); + return null == rotate ? getDefaultBeginShapeRotate() : rotate; + } + + public void setDefaultEndShape(Shape baseEndShape, boolean notify) { + this.defaultEndShape = baseEndShape; + if (notify) { + fireChangeEvent(); + } + } + + public Shape getDefaultEndShape() { + return defaultEndShape; + } + + public void setSeriesEndShape(int series, Shape shape, boolean notify) { + this.endShapes.setShape(series, shape); + if (notify) { + fireChangeEvent(); + } + } + + public Shape getSeriesEndShape(int series) { + Shape shape = this.endShapes.getShape(series); + return null == shape ? this.defaultEndShape : shape; + } + + public void setDefaultEndShapeRotate(Boolean baseEndShapeRotate, boolean notify) { + this.defaultEndShapeRotate = baseEndShapeRotate; + if (notify) { + fireChangeEvent(); + } + } + + public Boolean getDefaultEndShapeRotate() { + return null == this.defaultEndShapeRotate ? this.defaultShapeRotate : this.defaultEndShapeRotate; + } + + public void setSeriesEndShapeRotate(int series, boolean rotate, boolean notify) { + this.endShapesRotate.setBoolean(series, rotate); + if (notify) { + fireChangeEvent(); + } + } + + public boolean getSeriesEndShapeRotate(int series) { + Boolean rotate = this.endShapesRotate.getBoolean(series); + return null == rotate ? getDefaultEndShapeRotate() : rotate; + } + + @Override + public LegendItem getLegendItem(int datasetIndex, int series) { + LegendItem item = super.getLegendItem(datasetIndex, series); + item.setShape(lookupLegendShape(series)); + return item; + } + + @Override + public Shape lookupSeriesShape(int series) { + Shape shape = getSeriesEndShape(series); + if (null == shape) { + shape = getSeriesBeginShape(series); + } + if (null == shape) { + shape = super.lookupSeriesShape(series); + } + return shape; + } + + @Override + public XYItemRendererState initialise(Graphics2D g2, Rectangle2D dataArea, XYPlot plot, XYDataset data, + PlotRenderingInfo info) + { + XYItemRendererState state = super.initialise(g2, dataArea, plot, data, info); + // disable visible items optimization - it doesn't work for this renderer... + state.setProcessVisibleItemsOnly(false); + return state; + } + + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, + XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, + CrosshairState crosshairState, int pass) + { + if (!getItemVisible(series, item) || !(dataset instanceof IntervalXYDataset)) { return; } - IntervalXYDataset intervalDataset = (IntervalXYDataset) dataset; - double X0 = intervalDataset.getStartXValue(series, item); - double Y0 = intervalDataset.getStartYValue(series, item); - double X1 = intervalDataset.getEndXValue(series, item); - double Y1 = intervalDataset.getEndYValue(series, item); + IntervalXYDataset intervalDataset = (IntervalXYDataset)dataset; + double x0 = intervalDataset.getStartXValue(series, item); + double y0 = intervalDataset.getStartYValue(series, item); + double x1 = intervalDataset.getEndXValue(series, item); + double y1 = intervalDataset.getEndYValue(series, item); // only draw if we have good values - if (Double.isNaN(X0) || Double.isNaN(Y0) || Double.isNaN(X1) || Double.isNaN(Y1)) { - return; - } + if (Double.isNaN(x0) || Double.isNaN(y0) || Double.isNaN(x1) || Double.isNaN(y1)) { + return; + } RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); - double transX0 = domainAxis.valueToJava2D(X0, dataArea, xAxisLocation); - double transY0 = rangeAxis.valueToJava2D(Y0, dataArea, yAxisLocation); - double transX1 = domainAxis.valueToJava2D(X1, dataArea, xAxisLocation); - double transY1 = rangeAxis.valueToJava2D(Y1, dataArea, yAxisLocation); - - // only draw if we have good values - if (Double.isNaN(transX0) || Double.isNaN(transY0) || Double.isNaN(transX1) || Double.isNaN(transY1)) { - return; - } + double transX0 = domainAxis.valueToJava2D(x0, dataArea, xAxisLocation); + double transY0 = rangeAxis.valueToJava2D(y0, dataArea, yAxisLocation); + double transX1 = domainAxis.valueToJava2D(x1, dataArea, xAxisLocation); + double transY1 = rangeAxis.valueToJava2D(y1, dataArea, yAxisLocation); + + // only draw if we have good values + if (Double.isNaN(transX0) || Double.isNaN(transY0) || Double.isNaN(transX1) || Double.isNaN(transY1)) { + return; + } PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { state.workingLine.setLine(transY0, transX0, transY1, transX1); - } - else if (orientation == PlotOrientation.VERTICAL) { + } else if (orientation == PlotOrientation.VERTICAL) { state.workingLine.setLine(transX0, transY0, transX1, transY1); } - boolean edgeVisible = drawEdge(g2, state, dataArea, dataset, series, item); + boolean edgeVisible = drawEdge(g2, state, dataArea, dataset, series, item); if (edgeVisible && isItemLabelVisible(series, item)) { - double centerX = transX0 * 0.5 + transX1 * 0.5; - double centerY = transY0 * 0.5 + transY1 * 0.5; - drawItemLabel(g2, orientation, dataset, series, item, centerX, centerY, false); + double centerX = transX0 * 0.5 + transX1 * 0.5; + double centerY = transY0 * 0.5 + transY1 * 0.5; + drawItemLabel(g2, orientation, dataset, series, item, centerX, centerY, false); } - } - - protected boolean drawEdge(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, XYDataset dataset, - int series, int item) { - Line2D line = state.workingLine; - - boolean beginVisible = dataArea.contains(line.getP1()); - boolean endVisible = dataArea.contains(line.getP2()); + } + + protected boolean drawEdge(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, XYDataset dataset, + int series, int item) + { + Line2D line = state.workingLine; + + boolean beginVisible = dataArea.contains(line.getP1()); + boolean endVisible = dataArea.contains(line.getP2()); if (!beginVisible && !endVisible && !getSeriesDrawPlotCrossingLines(series)) { - return false; + return false; } - - // Copy the line before clipping as we need it to create begin/end shapes - Line2D fullLine = (Line2D) line.clone(); + + // Copy the line before clipping as we need it to create begin/end shapes + Line2D fullLine = (Line2D)line.clone(); boolean lineVisible = LineUtils.clipLine(line, dataArea); if (!lineVisible) { - return false; + return false; } - - Stroke itemStroke = getItemStroke(series, item); + + Stroke itemStroke = getItemStroke(series, item); g2.setStroke(itemStroke); g2.setPaint(getItemPaint(series, item)); - g2.draw(line); - + g2.draw(line); + Shape beginShape = null; if (beginVisible) { - beginShape = createBeginShape(fullLine, series); - if (null != beginShape) { - g2.fill(beginShape); - } + beginShape = createBeginShape(fullLine, series); + if (null != beginShape) { + g2.fill(beginShape); + } } Shape endShape = null; if (endVisible) { - endShape = createEndShape(fullLine, series); - if (null != endShape) { - g2.fill(endShape); - } + endShape = createEndShape(fullLine, series); + if (null != endShape) { + g2.fill(endShape); + } } - + EntityCollection entities = state.getEntityCollection(); if (entities != null) { - Area hotspot = new Area(ShapeUtils.createLineRegion(line, calculateLineWidth(itemStroke))); + Area hotspot = new Area(ShapeUtils.createLineRegion(line, calculateLineWidth(itemStroke))); if (null != beginShape) { - hotspot.add(new Area(beginShape)); + hotspot.add(new Area(beginShape)); } if (null != endShape) { - hotspot.add(new Area(endShape)); + hotspot.add(new Area(endShape)); } hotspot.intersect(new Area(dataArea)); addEntity(entities, hotspot, dataset, series, item, 0.0, 0.0); } return true; - } - - protected Shape createBeginShape(Line2D line, int series) { - Shape shape = getSeriesBeginShape(series); - if (null == shape) { - return null; - } - double tx = shape.getBounds2D().getCenterX(); - double ty = shape.getBounds2D().getCenterY(); - AffineTransform aff = new AffineTransform(); - aff.translate(line.getX1() - tx, line.getY1() - ty); - if (getSeriesBeginShapeRotate(series)) { - double angle = Math.atan2(line.getY2() - line.getY1(), line.getX2() - line.getX1()); - aff.rotate(angle, tx, ty); - } - return aff.createTransformedShape(shape); - } - - protected Shape createEndShape(Line2D line, int series) { - Shape shape = getSeriesEndShape(series); - if (null == shape) { - return null; - } - double tx = shape.getBounds2D().getCenterX(); - double ty = shape.getBounds2D().getCenterY(); - AffineTransform aff = new AffineTransform(); - aff.translate(line.getX2() - tx, line.getY2() - ty); - if (getSeriesEndShapeRotate(series)) { - double angle = Math.atan2(line.getY2() - line.getY1(), line.getX2() - line.getX1()); - aff.rotate(angle, tx, ty); - } - return aff.createTransformedShape(shape); - } - - protected float calculateLineWidth(Stroke stroke) { - return (float) stroke.createStrokedShape(new Line2D.Double(0, 0, 100, 0)).getBounds2D().getHeight(); - } -} \ No newline at end of file + } + + protected Shape createBeginShape(Line2D line, int series) { + Shape shape = getSeriesBeginShape(series); + if (null == shape) { + return null; + } + double tx = shape.getBounds2D().getCenterX(); + double ty = shape.getBounds2D().getCenterY(); + AffineTransform aff = new AffineTransform(); + aff.translate(line.getX1() - tx, line.getY1() - ty); + if (getSeriesBeginShapeRotate(series)) { + double angle = Math.atan2(line.getY2() - line.getY1(), line.getX2() - line.getX1()); + aff.rotate(angle, tx, ty); + } + return aff.createTransformedShape(shape); + } + + protected Shape createEndShape(Line2D line, int series) { + Shape shape = getSeriesEndShape(series); + if (null == shape) { + return null; + } + double tx = shape.getBounds2D().getCenterX(); + double ty = shape.getBounds2D().getCenterY(); + AffineTransform aff = new AffineTransform(); + aff.translate(line.getX2() - tx, line.getY2() - ty); + if (getSeriesEndShapeRotate(series)) { + double angle = Math.atan2(line.getY2() - line.getY1(), line.getX2() - line.getX1()); + aff.rotate(angle, tx, ty); + } + return aff.createTransformedShape(shape); + } + + protected float calculateLineWidth(Stroke stroke) { + return (float)stroke.createStrokedShape(new Line2D.Double(0, 0, 100, 0)).getBounds2D().getHeight(); + } +} diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/renderer/xy/XYImageRenderer.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/renderer/xy/XYImageRenderer.java index 96b72daec6852060f8f9778df0aeb5e60afa9990..aa0ebec7e514e1f057455d033c9b965b73495b19 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/renderer/xy/XYImageRenderer.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/chart/renderer/xy/XYImageRenderer.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.chart.renderer.xy; import java.awt.Graphics2D; @@ -30,41 +31,42 @@ import org.jfree.data.xy.XYDataset; * Renders a {@link BufferedImage} at for every item in an {@link XYDataset}. */ public class XYImageRenderer extends AbstractXYItemRenderer { - private static final long serialVersionUID = 3581068448737775534L; - - private BufferedImage defaultImage = null; - private RectangleAnchor defaultAnchor = RectangleAnchor.CENTER; - - public void setDefaultImage(BufferedImage baseImage) { - this.defaultImage = baseImage; - } - - public BufferedImage getDefaultImage() { - return defaultImage; - } - - public RectangleAnchor getDefaultAnchor() { - return defaultAnchor; - } - - public void setDefaultAnchor(RectangleAnchor baseAnchor) { - this.defaultAnchor = baseAnchor; - } - - public BufferedImage getItemImage(int row, int column) { - return defaultImage; - } - - public RectangleAnchor getItemAnchor(int row, int column) { - return defaultAnchor; - } - - @Override - public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, - XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, - CrosshairState crosshairState, int pass) { - - // do nothing if item is not visible + private static final long serialVersionUID = 3581068448737775534L; + + private BufferedImage defaultImage = null; + + private RectangleAnchor defaultAnchor = RectangleAnchor.CENTER; + + public void setDefaultImage(BufferedImage baseImage) { + this.defaultImage = baseImage; + } + + public BufferedImage getDefaultImage() { + return defaultImage; + } + + public RectangleAnchor getDefaultAnchor() { + return defaultAnchor; + } + + public void setDefaultAnchor(RectangleAnchor baseAnchor) { + this.defaultAnchor = baseAnchor; + } + + public BufferedImage getItemImage(int row, int column) { + return defaultImage; + } + + public RectangleAnchor getItemAnchor(int row, int column) { + return defaultAnchor; + } + + @Override + public void drawItem(Graphics2D g2, XYItemRendererState state, Rectangle2D dataArea, PlotRenderingInfo info, + XYPlot plot, ValueAxis domainAxis, ValueAxis rangeAxis, XYDataset dataset, int series, int item, + CrosshairState crosshairState, int pass) + { + // do nothing if item is not visible if (!getItemVisible(series, item)) { return; } @@ -75,28 +77,27 @@ public class XYImageRenderer extends AbstractXYItemRenderer { BufferedImage image = getItemImage(series, item); RectangleAnchor anchor = getItemAnchor(series, item); if (Double.isNaN(x) || Double.isNaN(y) || null == image || null == anchor) { - return; + return; } - + RectangleEdge xAxisLocation = plot.getDomainAxisEdge(); RectangleEdge yAxisLocation = plot.getRangeAxisEdge(); - int transX = (int) Math.round(domainAxis.valueToJava2D(x, dataArea, xAxisLocation)); - int transY = (int) Math.round(rangeAxis.valueToJava2D(y, dataArea, yAxisLocation)); + int transX = (int)Math.round(domainAxis.valueToJava2D(x, dataArea, xAxisLocation)); + int transY = (int)Math.round(rangeAxis.valueToJava2D(y, dataArea, yAxisLocation)); - Rectangle2D imageRectangle = null; + Rectangle2D imageRectangle = null; PlotOrientation orientation = plot.getOrientation(); if (orientation == PlotOrientation.HORIZONTAL) { - imageRectangle = RectangleAnchor.createRectangle( - new Size2D(image.getWidth(), image.getHeight()), transY, transX, anchor); - } - else if (orientation == PlotOrientation.VERTICAL) { - imageRectangle = RectangleAnchor.createRectangle( - new Size2D(image.getWidth(), image.getHeight()), transX, transY, anchor); + imageRectangle = RectangleAnchor.createRectangle(new Size2D(image.getWidth(), image.getHeight()), transY, + transX, anchor); + } else if (orientation == PlotOrientation.VERTICAL) { + imageRectangle = RectangleAnchor.createRectangle(new Size2D(image.getWidth(), image.getHeight()), transX, + transY, anchor); } if (null != imageRectangle) { - int imageX = (int) Math.round(imageRectangle.getMinX()); - int imageY = (int) Math.round(imageRectangle.getMinY()); - g2.drawImage(image, null, imageX, imageY); + int imageX = (int)Math.round(imageRectangle.getMinX()); + int imageY = (int)Math.round(imageRectangle.getMinY()); + g2.drawImage(image, null, imageX, imageY); } int datasetIndex = plot.indexOf(dataset); @@ -106,5 +107,5 @@ public class XYImageRenderer extends AbstractXYItemRenderer { if (entities != null) { addEntity(entities, imageRectangle, dataset, series, item, 0.0, 0.0); } - } + } } diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/data/xy/XYEdgeDataItem.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/data/xy/XYEdgeDataItem.java index 80a38fba3b90d4777a2bc36f94a813e18ee0d6a6..bf9977c207269e37d2e4967798c7323f4686cb8b 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/data/xy/XYEdgeDataItem.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/data/xy/XYEdgeDataItem.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.data.xy; import java.io.Serializable; @@ -17,58 +18,61 @@ import org.jfree.chart.util.Args; * An item representing data as two points in the form (x0, y0 and x1, y1). */ public class XYEdgeDataItem implements Serializable { - private static final long serialVersionUID = -7116745427210808035L; - - private final Number x0; - private final Number y0; - private final Number x1; - private final Number y1; - - public XYEdgeDataItem(Number x0, Number y0, Number x1, Number y1) { - Args.nullNotPermitted(x0, "x0"); - Args.nullNotPermitted(x1, "x1"); - Args.nullNotPermitted(y0, "y0"); - Args.nullNotPermitted(y1, "y1"); - this.x0 = x0; - this.y0 = y0; - this.x1 = x1; - this.y1 = y1; - } - - public boolean isNaN() { - return Double.isNaN(getX0Value()) || Double.isNaN(getX1Value()) || Double.isNaN(getY0Value()) - || Double.isNaN(getY1Value()); - } - - public Number getX0() { - return x0; - } - - public Number getY0() { - return y0; - } - - public Number getX1() { - return x1; - } - - public Number getY1() { - return y1; - } - - public double getX0Value() { - return x0.doubleValue(); - } - - public double getY0Value() { - return y0.doubleValue(); - } - - public double getX1Value() { - return x1.doubleValue(); - } - - public double getY1Value() { - return y1.doubleValue(); - } -} \ No newline at end of file + private static final long serialVersionUID = -7116745427210808035L; + + private final Number x0; + + private final Number y0; + + private final Number x1; + + private final Number y1; + + public XYEdgeDataItem(Number x0, Number y0, Number x1, Number y1) { + Args.nullNotPermitted(x0, "x0"); + Args.nullNotPermitted(x1, "x1"); + Args.nullNotPermitted(y0, "y0"); + Args.nullNotPermitted(y1, "y1"); + this.x0 = x0; + this.y0 = y0; + this.x1 = x1; + this.y1 = y1; + } + + public boolean isNaN() { + return Double.isNaN(getX0Value()) || Double.isNaN(getX1Value()) || Double.isNaN(getY0Value()) + || Double.isNaN(getY1Value()); + } + + public Number getX0() { + return x0; + } + + public Number getY0() { + return y0; + } + + public Number getX1() { + return x1; + } + + public Number getY1() { + return y1; + } + + public double getX0Value() { + return x0.doubleValue(); + } + + public double getY0Value() { + return y0.doubleValue(); + } + + public double getX1Value() { + return x1.doubleValue(); + } + + public double getY1Value() { + return y1.doubleValue(); + } +} diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/data/xy/XYEdgeSeries.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/data/xy/XYEdgeSeries.java index 7884b6ae498c4de2b1cea772b503c3da8aa8d6cc..467c86ac7fb5253ecb976a1da4a0820e490daa45 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/data/xy/XYEdgeSeries.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/data/xy/XYEdgeSeries.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.data.xy; import java.util.ArrayList; @@ -21,66 +22,66 @@ import org.jfree.data.general.Series; * @see XYEdgeSeriesCollection */ public class XYEdgeSeries extends Series { - private static final long serialVersionUID = 7175710875342448296L; - - private final List items = new ArrayList<>(); - - public XYEdgeSeries(Comparable key) { - super(key); - } - - public XYEdgeSeries(Comparable key, String description) { - super(key, description); - } - - public void add(XYEdgeDataItem item, boolean notify) { - Args.nullNotPermitted(item, "item"); - items.add(item); - if (notify) { - fireSeriesChanged(); - } - } - - public void removeAllSeries() { - items.clear(); - fireSeriesChanged(); - } - - @Override - public int getItemCount() { - return items.size(); - } - - public XYEdgeDataItem getDataItem(int item) { - if ((item < 0) || (item >= getItemCount())) { - throw new IllegalArgumentException("Series index out of bounds"); - } - return items.get(item); - } - - public Number getX(int item) { - XYEdgeDataItem dataItem = getDataItem(item); - return (dataItem.getX0Value() * 0.5) + (dataItem.getX1Value() * 0.5); - } - - public Number getY(int item) { - XYEdgeDataItem dataItem = getDataItem(item); - return (dataItem.getY0Value() * 0.5) + (dataItem.getY1Value() * 0.5); - } - - public Number getStartX(int item) { - return getDataItem(item).getX0Value(); - } - - public Number getEndX(int item) { - return getDataItem(item).getX1Value(); - } - - public Number getStartY(int item) { - return getDataItem(item).getY0Value(); - } - - public Number getEndY(int item) { - return getDataItem(item).getY1Value(); - } -} \ No newline at end of file + private static final long serialVersionUID = 7175710875342448296L; + + private final List items = new ArrayList<>(); + + public XYEdgeSeries(Comparable key) { + super(key); + } + + public XYEdgeSeries(Comparable key, String description) { + super(key, description); + } + + public void add(XYEdgeDataItem item, boolean notify) { + Args.nullNotPermitted(item, "item"); + items.add(item); + if (notify) { + fireSeriesChanged(); + } + } + + public void removeAllSeries() { + items.clear(); + fireSeriesChanged(); + } + + @Override + public int getItemCount() { + return items.size(); + } + + public XYEdgeDataItem getDataItem(int item) { + if ((item < 0) || (item >= getItemCount())) { + throw new IllegalArgumentException("Series index out of bounds"); + } + return items.get(item); + } + + public Number getX(int item) { + XYEdgeDataItem dataItem = getDataItem(item); + return (dataItem.getX0Value() * 0.5) + (dataItem.getX1Value() * 0.5); + } + + public Number getY(int item) { + XYEdgeDataItem dataItem = getDataItem(item); + return (dataItem.getY0Value() * 0.5) + (dataItem.getY1Value() * 0.5); + } + + public Number getStartX(int item) { + return getDataItem(item).getX0Value(); + } + + public Number getEndX(int item) { + return getDataItem(item).getX1Value(); + } + + public Number getStartY(int item) { + return getDataItem(item).getY0Value(); + } + + public Number getEndY(int item) { + return getDataItem(item).getY1Value(); + } +} diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/data/xy/XYEdgeSeriesCollection.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/data/xy/XYEdgeSeriesCollection.java index cfc9823cbdbec06c3e4508edaeb94bd36acb5df6..8c9e9aa1f4423c5b3c0e6f8d24452b9702d4f063 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/data/xy/XYEdgeSeriesCollection.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/data/xy/XYEdgeSeriesCollection.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.data.xy; import java.beans.PropertyChangeEvent; @@ -22,38 +23,35 @@ import org.jfree.data.xy.AbstractIntervalXYDataset; import org.jfree.data.xy.IntervalXYDataset; /** - * Represents a collection of {@link XYEdgeSeries} objects that can be used as a - * dataset. + * Represents a collection of {@link XYEdgeSeries} objects that can be used as a dataset. */ public class XYEdgeSeriesCollection extends AbstractIntervalXYDataset - implements IntervalXYDataset, VetoableChangeListener, PublicCloneable, Serializable { - private static final long serialVersionUID = -371610910545736704L; + implements IntervalXYDataset, VetoableChangeListener, PublicCloneable, Serializable +{ + private static final long serialVersionUID = -371610910545736704L; - private final ArrayList data = new ArrayList<>(); + private final ArrayList data = new ArrayList<>(); - public XYEdgeSeriesCollection() { - // Empty - } + public XYEdgeSeriesCollection() { + // Empty + } - public XYEdgeSeriesCollection(XYEdgeSeries series) { - addSeries(series); - } + public XYEdgeSeriesCollection(XYEdgeSeries series) { + addSeries(series); + } /** - * Adds a series to the collection and sends a {@link DatasetChangeEvent} - * to all registered listeners. + * Adds a series to the collection and sends a {@link DatasetChangeEvent} to all registered listeners. * - * @param series the series ({@code null} not permitted). - * - * @throws IllegalArgumentException if the key for the series is null or - * not unique within the dataset. + * @param series the series ({@code null} not permitted). + * + * @throws IllegalArgumentException if the key for the series is null or not unique within the dataset. */ public void addSeries(XYEdgeSeries series) { Args.nullNotPermitted(series, "series"); if (getSeriesIndex(series.getKey()) >= 0) { throw new IllegalArgumentException( - "This dataset already contains a series with the key " - + series.getKey()); + "This dataset already contains a series with the key " + series.getKey()); } this.data.add(series); series.addChangeListener(this); @@ -61,37 +59,36 @@ public class XYEdgeSeriesCollection extends AbstractIntervalXYDataset fireDatasetChanged(); } - public void removeAllSeries() { - data.forEach(s -> s.removeChangeListener(this)); - data.clear(); - fireDatasetChanged(); - } + public void removeAllSeries() { + data.forEach(s -> s.removeChangeListener(this)); + data.clear(); + fireDatasetChanged(); + } - @Override - public int getSeriesCount() { - return data.size(); - } + @Override + public int getSeriesCount() { + return data.size(); + } - public XYEdgeSeries getSeries(int series) { - if ((series < 0) || (series >= getSeriesCount())) { - throw new IllegalArgumentException("Series index out of bounds"); - } - return data.get(series); - } + public XYEdgeSeries getSeries(int series) { + if ((series < 0) || (series >= getSeriesCount())) { + throw new IllegalArgumentException("Series index out of bounds"); + } + return data.get(series); + } /** - * Returns the index of the series with the specified key, or -1 if no - * series has that key. - * - * @param key the key ({@code null} not permitted). - * + * Returns the index of the series with the specified key, or -1 if no series has that key. + * + * @param key the key ({@code null} not permitted). + * * @return The index. */ public int getSeriesIndex(Comparable key) { Args.nullNotPermitted(key, "key"); int seriesCount = getSeriesCount(); for (int i = 0; i < seriesCount; i++) { - XYEdgeSeries series = this.data.get(i); + XYEdgeSeries series = this.data.get(i); if (key.equals(series.getKey())) { return i; } @@ -100,63 +97,63 @@ public class XYEdgeSeriesCollection extends AbstractIntervalXYDataset } @Override - public Comparable getSeriesKey(int series) { - return getSeries(series).getKey(); - } - - @Override - public int getItemCount(int series) { - return getSeries(series).getItemCount(); - } - - @Override - public Number getX(int series, int item) { - return getSeries(series).getX(item); - } - - @Override - public Number getY(int series, int item) { - return getSeries(series).getY(item); - } - - @Override - public Number getStartX(int series, int item) { - return getSeries(series).getStartX(item); - } - - @Override - public Number getEndX(int series, int item) { - return getSeries(series).getEndX(item); - } - - @Override - public Number getStartY(int series, int item) { - return getSeries(series).getStartY(item); - } - - @Override - public Number getEndY(int series, int item) { - return getSeries(series).getEndY(item); - } - - @Override - public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException { - // if it is not the series name, then we have no interest - if (!"Key".equals(e.getPropertyName())) { - return; - } - - // to be defensive, let's check that the source series does in fact - // belong to this collection - XYEdgeSeries s = (XYEdgeSeries) e.getSource(); - if (getSeriesIndex(s.getKey()) == -1) { - throw new IllegalStateException( - "Receiving events from a series " + "that does not belong to this collection."); - } - // check if the new series name already exists for another series - Comparable key = (Comparable) e.getNewValue(); - if (getSeriesIndex(key) >= 0) { - throw new PropertyVetoException("Duplicate key2", e); - } - } -} \ No newline at end of file + public Comparable getSeriesKey(int series) { + return getSeries(series).getKey(); + } + + @Override + public int getItemCount(int series) { + return getSeries(series).getItemCount(); + } + + @Override + public Number getX(int series, int item) { + return getSeries(series).getX(item); + } + + @Override + public Number getY(int series, int item) { + return getSeries(series).getY(item); + } + + @Override + public Number getStartX(int series, int item) { + return getSeries(series).getStartX(item); + } + + @Override + public Number getEndX(int series, int item) { + return getSeries(series).getEndX(item); + } + + @Override + public Number getStartY(int series, int item) { + return getSeries(series).getStartY(item); + } + + @Override + public Number getEndY(int series, int item) { + return getSeries(series).getEndY(item); + } + + @Override + public void vetoableChange(PropertyChangeEvent e) throws PropertyVetoException { + // if it is not the series name, then we have no interest + if (!"Key".equals(e.getPropertyName())) { + return; + } + + // to be defensive, let's check that the source series does in fact + // belong to this collection + XYEdgeSeries s = (XYEdgeSeries)e.getSource(); + if (getSeriesIndex(s.getKey()) == -1) { + throw new IllegalStateException( + "Receiving events from a series " + "that does not belong to this collection."); + } + // check if the new series name already exists for another series + Comparable key = (Comparable)e.getNewValue(); + if (getSeriesIndex(key) >= 0) { + throw new PropertyVetoException("Duplicate key2", e); + } + } +} diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/data/xy/XYScaledSeries.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/data/xy/XYScaledSeries.java index ae5fdacf19b6c8806b8552d56d3754c0bef5748a..2cbfcb8ebf7cc90c3e20d58471533848ddad2b82 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/data/xy/XYScaledSeries.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/data/xy/XYScaledSeries.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.data.xy; import org.eclipse.trace4cps.common.jfreechart.chart.axis.Section; @@ -15,164 +16,152 @@ import org.jfree.data.Range; import org.jfree.data.xy.XYSeries; /** - * A special {@link XYSeries} that allows to scale its values to fit a certain - * range. This series can be used to bound values to a specific {@link Section} - * on a {@link SectionAxis}. + * A special {@link XYSeries} that allows to scale its values to fit a certain range. This series can be used to bound + * values to a specific {@link Section} on a {@link SectionAxis}. * * @param the key type * @see SectionAxis */ public class XYScaledSeries extends XYSeries { - private static final long serialVersionUID = 5321740573688656080L; - private final Range scaledXRange; - private final Range scaledYRange; - - /** - * Creates a new empty series. By default, items added to the series will be - * sorted into ascending order by x-value, and duplicate x-values will be - * allowed (these defaults can be modified with another constructor). - * - * @param key the series key ({@code null} not permitted). - * @param XScale the scale to use for the X-axis, {@code null} if scaling is not - * required for the X-axis. - * @param XScale the scale to use for the Y-axis, {@code null} if scaling is not - * required for the Y-axis. - */ - public XYScaledSeries(Comparable key, Range XScale, Range YScale) { - this(key, XScale, YScale, true, true); - } - - /** - * Constructs a new empty series, with the auto-sort flag set as requested, and - * duplicate values allowed. - * - * @param key the series key ({@code null} not permitted). - * @param XScale the scale to use for the X-axis, {@code null} if scaling is - * not required for the X-axis. - * @param XScale the scale to use for the Y-axis, {@code null} if scaling is - * not required for the Y-axis. - * @param autoSort a flag that controls whether or not the items in the series - * are sorted. - */ - public XYScaledSeries(Comparable key, Range XScale, Range YScale, boolean autoSort) { - this(key, XScale, YScale, autoSort, true); - } - - /** - * Constructs a new xy-series that contains no data. You can specify whether or - * not duplicate x-values are allowed for the series. - * - * @param key the series key ({@code null} not permitted). - * @param XScale the scale to use for the X-axis, {@code null} if - * scaling is not required for the X-axis. - * @param XScale the scale to use for the Y-axis, {@code null} if - * scaling is not required for the Y-axis. - * @param autoSort a flag that controls whether or not the items in - * the series are sorted. - * @param allowDuplicateXValues a flag that controls whether duplicate x-values - * are allowed. - */ - public XYScaledSeries(Comparable key, Range XScale, Range YScale, boolean autoSort, boolean allowDuplicateXValues) { - super(key, autoSort, allowDuplicateXValues); - this.scaledXRange = XScale; - this.scaledYRange = YScale; - } - - @Override - public double getMinX() { - return null == scaledXRange ? super.getMinX() : scaledXRange.getLowerBound(); - } - - @Override - public double getMinY() { - return null == scaledYRange ? super.getMinY() : scaledYRange.getLowerBound(); - } - - @Override - public double getMaxX() { - return null == scaledXRange ? super.getMaxX() : scaledXRange.getUpperBound(); - } - - @Override - public double getMaxY() { - return null == scaledYRange ? super.getMaxY() : scaledYRange.getUpperBound(); - } - - @Override - public Number getX(int index) { - Number original = super.getX(index); - if (null == original || null == scaledXRange) - return original; - - double originalPercentage = (original.doubleValue() - super.getMinX()) / (super.getMaxX() - super.getMinX()); - return scaledXRange.getLowerBound() + (originalPercentage * scaledXRange.getLength()); - } - - @Override - public Number getY(int index) { - Number original = super.getY(index); - if (null == original || null == scaledYRange) - return original; - - double originalPercentage = (original.doubleValue() - super.getMinY()) / (super.getMaxY() - super.getMinY()); - return scaledYRange.getLowerBound() + (originalPercentage * scaledYRange.getLength()); - } - - /** - * Returns the smallest unscaled (a.k.a. original) x-value in the series, - * ignoring any Double.NaN values. This method returns Double.NaN if there is no - * smallest x-value (for example, when the series is empty). - * - * @return The smallest x-value. - * - * @see #getMaxX() - */ - public double getUnscaledMinX() { - return super.getMinX(); - } - - /** - * Returns the smallest unscaled (a.k.a. original) y-value in the series, - * ignoring any null and Double.NaN values. This method returns Double.NaN if - * there is no smallest y-value (for example, when the series is empty). - * - * @return The smallest y-value. - * - * @see #getMaxY() - */ - public double getUnscaledMinY() { - return super.getMinY(); - } - - /** - * Returns the largest unscaled (a.k.a. original) x-value in the series, - * ignoring any Double.NaN values. This method returns Double.NaN if there is no - * largest x-value (for example, when the series is empty). - * - * @return The largest x-value. - * - * @see #getMinX() - */ - public double getUnscaledMaxX() { - return super.getMaxX(); - } - - /** - * Returns the largest unscaled (a.k.a. original) y-value in the series, - * ignoring any Double.NaN values. This method returns Double.NaN if there is no - * largest y-value (for example, when the series is empty). - * - * @return The largest y-value. - * - * @see #getMinY() - */ - public double getUnscaledMaxY() { - return super.getMaxY(); - } + private static final long serialVersionUID = 5321740573688656080L; + + private final Range scaledXRange; + + private final Range scaledYRange; + + /** + * Creates a new empty series. By default, items added to the series will be sorted into ascending order by x-value, + * and duplicate x-values will be allowed (these defaults can be modified with another constructor). + * + * @param key the series key ({@code null} not permitted). + * @param XScale the scale to use for the X-axis, {@code null} if scaling is not required for the X-axis. + * @param XScale the scale to use for the Y-axis, {@code null} if scaling is not required for the Y-axis. + */ + public XYScaledSeries(Comparable key, Range XScale, Range YScale) { + this(key, XScale, YScale, true, true); + } + + /** + * Constructs a new empty series, with the auto-sort flag set as requested, and duplicate values allowed. + * + * @param key the series key ({@code null} not permitted). + * @param XScale the scale to use for the X-axis, {@code null} if scaling is not required for the X-axis. + * @param XScale the scale to use for the Y-axis, {@code null} if scaling is not required for the Y-axis. + * @param autoSort a flag that controls whether or not the items in the series are sorted. + */ + public XYScaledSeries(Comparable key, Range XScale, Range YScale, boolean autoSort) { + this(key, XScale, YScale, autoSort, true); + } /** - * Returns the range from the smallest until the largest unscaled (a.k.a. - * original) x-values in the series, ignoring any Double.NaN values. + * Constructs a new xy-series that contains no data. You can specify whether or not duplicate x-values are allowed + * for the series. + * + * @param key the series key ({@code null} not permitted). + * @param XScale the scale to use for the X-axis, {@code null} if scaling is not required for the X-axis. + * @param XScale the scale to use for the Y-axis, {@code null} if scaling is not required for the Y-axis. + * @param autoSort a flag that controls whether or not the items in the series are sorted. + * @param allowDuplicateXValues a flag that controls whether duplicate x-values are allowed. + */ + public XYScaledSeries(Comparable key, Range XScale, Range YScale, boolean autoSort, + boolean allowDuplicateXValues) + { + super(key, autoSort, allowDuplicateXValues); + this.scaledXRange = XScale; + this.scaledYRange = YScale; + } + + @Override + public double getMinX() { + return null == scaledXRange ? super.getMinX() : scaledXRange.getLowerBound(); + } + + @Override + public double getMinY() { + return null == scaledYRange ? super.getMinY() : scaledYRange.getLowerBound(); + } + + @Override + public double getMaxX() { + return null == scaledXRange ? super.getMaxX() : scaledXRange.getUpperBound(); + } + + @Override + public double getMaxY() { + return null == scaledYRange ? super.getMaxY() : scaledYRange.getUpperBound(); + } + + @Override + public Number getX(int index) { + Number original = super.getX(index); + if (null == original || null == scaledXRange) + return original; + + double originalPercentage = (original.doubleValue() - super.getMinX()) / (super.getMaxX() - super.getMinX()); + return scaledXRange.getLowerBound() + (originalPercentage * scaledXRange.getLength()); + } + + @Override + public Number getY(int index) { + Number original = super.getY(index); + if (null == original || null == scaledYRange) + return original; + + double originalPercentage = (original.doubleValue() - super.getMinY()) / (super.getMaxY() - super.getMinY()); + return scaledYRange.getLowerBound() + (originalPercentage * scaledYRange.getLength()); + } + + /** + * Returns the smallest unscaled (a.k.a. original) x-value in the series, ignoring any Double.NaN values. This + * method returns Double.NaN if there is no smallest x-value (for example, when the series is empty). + * + * @return The smallest x-value. + * + * @see #getMaxX() + */ + public double getUnscaledMinX() { + return super.getMinX(); + } + + /** + * Returns the smallest unscaled (a.k.a. original) y-value in the series, ignoring any null and Double.NaN values. + * This method returns Double.NaN if there is no smallest y-value (for example, when the series is empty). + * + * @return The smallest y-value. + * + * @see #getMaxY() + */ + public double getUnscaledMinY() { + return super.getMinY(); + } + + /** + * Returns the largest unscaled (a.k.a. original) x-value in the series, ignoring any Double.NaN values. This method + * returns Double.NaN if there is no largest x-value (for example, when the series is empty). + * + * @return The largest x-value. + * + * @see #getMinX() + */ + public double getUnscaledMaxX() { + return super.getMaxX(); + } + + /** + * Returns the largest unscaled (a.k.a. original) y-value in the series, ignoring any Double.NaN values. This method + * returns Double.NaN if there is no largest y-value (for example, when the series is empty). + * + * @return The largest y-value. + * + * @see #getMinY() + */ + public double getUnscaledMaxY() { + return super.getMaxY(); + } + + /** + * Returns the range from the smallest until the largest unscaled (a.k.a. original) x-values in the series, ignoring + * any Double.NaN values. * * @return the range from the smallest until the largest unscaled x-values * @@ -182,10 +171,10 @@ public class XYScaledSeries extends XYSeries { public Range getUnscaledRangeX() { return new Range(getUnscaledMinX(), getUnscaledMaxX()); } - + /** - * Returns the range from the smallest until the largest unscaled (a.k.a. - * original) y-values in the series, ignoring any Double.NaN values. + * Returns the range from the smallest until the largest unscaled (a.k.a. original) y-values in the series, ignoring + * any Double.NaN values. * * @return the range from the smallest until the largest unscaled y-values * @@ -195,26 +184,26 @@ public class XYScaledSeries extends XYSeries { public Range getUnscaledRangeY() { return new Range(getUnscaledMinY(), getUnscaledMaxY()); } - - /** - * Returns the unscaled (a.k.a. original) x-value at the specified index. - * - * @param index the index (zero-based). - * - * @return The x-value (never {@code null}). - */ - public Number getUnscaledX(int index) { - return super.getX(index); - } - - /** - * Returns the unscaled (a.k.a. original) y-value at the specified index. - * - * @param index the index (zero-based). - * - * @return The y-value (possibly {@code null}). - */ - public Number getUnscaledY(int index) { - return super.getY(index); - } + + /** + * Returns the unscaled (a.k.a. original) x-value at the specified index. + * + * @param index the index (zero-based). + * + * @return The x-value (never {@code null}). + */ + public Number getUnscaledX(int index) { + return super.getX(index); + } + + /** + * Returns the unscaled (a.k.a. original) y-value at the specified index. + * + * @param index the index (zero-based). + * + * @return The y-value (possibly {@code null}). + */ + public Number getUnscaledY(int index) { + return super.getY(index); + } } diff --git a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/data/xy/XYScaledSeriesCollection.java b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/data/xy/XYScaledSeriesCollection.java index 79094206906629daae7039e22cf5de2cbe8f2a0e..f82b642a5d8e5393bd25a81a61fd2d1d00f0c7d8 100644 --- a/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/data/xy/XYScaledSeriesCollection.java +++ b/jfreechart/org.eclipse.trace4cps.common.jfreechart/src/org/eclipse/trace4cps/common/jfreechart/data/xy/XYScaledSeriesCollection.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.common.jfreechart.data.xy; import java.util.List; @@ -18,9 +19,8 @@ import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; /** - * A special {@link XYSeriesCollection} that allows to scale its values to fit a certain - * range. This dataset can be used to bound values to a specific {@link Section} - * on a {@link SectionAxis}. + * A special {@link XYSeriesCollection} that allows to scale its values to fit a certain range. This dataset can be used + * to bound values to a specific {@link Section} on a {@link SectionAxis}. * * @see SectionAxis * @see XYScaledSeries @@ -38,8 +38,7 @@ public class XYScaledSeriesCollection extends XYSeriesCollection { /** * @deprecated use {@link #addSeries(XYScaledSeries)} - * @throws ClassCastException if {@code series} is not instance of - * {@link XYScaledSeries} + * @throws ClassCastException if {@code series} is not instance of {@link XYScaledSeries} */ @Override @Deprecated @@ -48,13 +47,11 @@ public class XYScaledSeriesCollection extends XYSeriesCollection { } /** - * Adds a series to the collection and sends a {@link DatasetChangeEvent} to - * all registered listeners. + * Adds a series to the collection and sends a {@link DatasetChangeEvent} to all registered listeners. * * @param series the series ({@code null} not permitted). - * - * @throws IllegalArgumentException if the key for the series is null or not - * unique within the dataset. + * + * @throws IllegalArgumentException if the key for the series is null or not unique within the dataset. * @see XYSeriesCollection#addSeries(XYSeries) */ public void addSeries(XYScaledSeries series) { @@ -64,26 +61,25 @@ public class XYScaledSeriesCollection extends XYSeriesCollection { @Override @SuppressWarnings("unchecked") public List getSeries() { - return (List) super.getSeries(); + return super.getSeries(); } @Override public XYScaledSeries getSeries(int series) { - return (XYScaledSeries) super.getSeries(series); + return (XYScaledSeries)super.getSeries(series); } @Override @SuppressWarnings("rawtypes") public XYScaledSeries getSeries(Comparable key) { - return (XYScaledSeries) super.getSeries(key); + return (XYScaledSeries)super.getSeries(key); } /** - * Returns the unscaled (a.k.a. original) x-value for the specified series - * and item. + * Returns the unscaled (a.k.a. original) x-value for the specified series and item. * * @param series the series (zero-based index). - * @param item the item (zero-based index). + * @param item the item (zero-based index). * * @return The unscaled (a.k.a. original) value. */ @@ -92,15 +88,14 @@ public class XYScaledSeriesCollection extends XYSeriesCollection { } /** - * Returns the unscaled (a.k.a. original) y-value for the specified series - * and item. + * Returns the unscaled (a.k.a. original) y-value for the specified series and item. * * @param series the series (zero-based index). - * @param item the item (zero-based). + * @param item the item (zero-based). * * @return The unscaled (a.k.a. original) value (possibly {@code null}). */ public Number getUnscaledY(int series, int item) { return getSeries(series).getUnscaledY(item); } -} \ No newline at end of file +} diff --git a/releng/org.eclipse.trace4cps.configuration/checkstyle.xml b/releng/org.eclipse.trace4cps.configuration/checkstyle.xml new file mode 100644 index 0000000000000000000000000000000000000000..525089bc68701f0faab86a6cd02386f2734e70c1 --- /dev/null +++ b/releng/org.eclipse.trace4cps.configuration/checkstyle.xml @@ -0,0 +1,281 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/releng/org.eclipse.trace4cps.configuration/pom.xml b/releng/org.eclipse.trace4cps.configuration/pom.xml index 81bd51b19737c8a67ef78122498cf1ae0cda7d1f..f2a9b698a98c06f8f8f5348e304ab86082dae287 100644 --- a/releng/org.eclipse.trace4cps.configuration/pom.xml +++ b/releng/org.eclipse.trace4cps.configuration/pom.xml @@ -10,20 +10,20 @@ --> - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 org.eclipse.trace4cps - org.eclipse.trace4cps.configuration + org.eclipse.trace4cps.configuration 0.1.0-SNAPSHOT pom - + 1.8 ${java.source} ${java.source} - + UTF-8 UTF-8 @@ -34,18 +34,25 @@ false - - 2.22.0 + + 2.22.0 2.11.3 0.0.1-SNAPSHOT + + + 3.1.2 + 8.41 - - + dash-licenses-snapshots https://repo.eclipse.org/content/repositories/dash-licenses-snapshots/ @@ -96,16 +103,18 @@ - - org.eclipse.trace4cps - org.eclipse.trace4cps.target - 0.1.0-SNAPSHOT - + + org.eclipse.trace4cps + org.eclipse.trace4cps.target + 0.1.0-SNAPSHOT + - - - + linux @@ -140,52 +149,53 @@ - - - org.eclipse.xtend - xtend-maven-plugin - ${xtext.version} - - - - compile - xtend-install-debug-info - - - - - ${project.basedir}/xtend-gen - ${project.basedir}/xtend-gen - - - - org.apache.maven.plugins - maven-clean-plugin - 3.1.0 - - - - ${project.basedir}/xtend-gen - - **/* - - - - - + + + org.eclipse.xtend + xtend-maven-plugin + ${xtext.version} + + + + compile + xtend-install-debug-info + + + + + ${project.basedir}/xtend-gen + ${project.basedir}/xtend-gen + + + + org.apache.maven.plugins + maven-clean-plugin + 3.1.0 + + + + ${project.basedir}/xtend-gen + + **/* + + + + + - - - - - - - - - + org.eclipse.m2e lifecycle-mapping @@ -206,27 +216,42 @@ + + + org.apache.maven.plugins + maven-checkstyle-plugin + [3.1.2,) + + check + + + + + + - - org.eclipse.tycho - tycho-versions-plugin - ${tycho.version} - - - - org.eclipse.tycho - tycho-surefire-plugin - ${tycho.version} - - - - - - + + org.eclipse.tycho + tycho-versions-plugin + ${tycho.version} + + + + org.eclipse.tycho + tycho-surefire-plugin + ${tycho.version} + + + org.eclipse.dash license-tool-plugin @@ -235,53 +260,97 @@ technology.trace4cps - - - com.mycila - license-maven-plugin - 4.1 - - - XML_STYLE - XML_STYLE - SCRIPT_STYLE - JAVADOC_STYLE - XML_STYLE - JAVADOC_STYLE - JAVADOC_STYLE - JAVADOC_STYLE - JAVADOC_STYLE - SCRIPT_STYLE - BATCH - BATCH - APOSTROPHE_STYLE - - - -
${session.executionRootDirectory}/releng/legal-defaults/license-header.txt
- true - - **/*.txt - **/*.ecore - **/*.genmodel - **/*.setup - **/*.target - **/*.launch - src-gen/** - xtend-gen/** - plugin.xml_gen - .polyglot.* - .META-INF_MANIFEST.MF - -
-
-
-
+ + + com.mycila + license-maven-plugin + 4.1 + + + XML_STYLE + XML_STYLE + SCRIPT_STYLE + JAVADOC_STYLE + XML_STYLE + JAVADOC_STYLE + JAVADOC_STYLE + JAVADOC_STYLE + JAVADOC_STYLE + SCRIPT_STYLE + BATCH + BATCH + APOSTROPHE_STYLE + + + +
${session.executionRootDirectory}/releng/legal-defaults/license-header.txt
+ true + + **/*.txt + **/*.ecore + **/*.genmodel + **/*.setup + **/*.target + **/*.launch + src-gen/** + xtend-gen/** + plugin.xml_gen + .polyglot.* + .META-INF_MANIFEST.MF + +
+
+
+
+ + + checkstyle-check + + + ${basedir}/.checkstyle + + + + + + org.apache.maven.plugins + maven-checkstyle-plugin + ${maven.checkstyle.version} + + + com.puppycrawl.tools + checkstyle + ${checkstyle.version} + + + + + checkstyle-validate + validate + + checkstyle.xml + false + true + info + + ${basedir}/src + + + + check + + + + + + + + add-plugin-default-abouts @@ -327,84 +396,86 @@ - - create-plugin-source - - - ${basedir}/META-INF/MANIFEST.MF - - - - - - org.eclipse.tycho - tycho-source-plugin - ${tycho.version} - - - plugin-source - - plugin-source - - - - - - - + + create-plugin-source + + + ${basedir}/META-INF/MANIFEST.MF + + + + + + org.eclipse.tycho + tycho-source-plugin + ${tycho.version} + + + plugin-source + + plugin-source + + + + + + + - - create-feature-source - - - ${basedir}/feature.xml - - - - - - org.eclipse.tycho.extras - tycho-source-feature-plugin - ${tycho.extras.version} - - ${source.feature.skip} - FAIL - - - - source-feature - - source-feature - - - - - - org.eclipse.tycho - tycho-p2-plugin - ${tycho.version} - - - - - - default-p2-metadata-default - - false - - - - - attach-p2-metadata - package - - p2-metadata - - - - - - - - + + create-feature-source + + + ${basedir}/feature.xml + + + + + + org.eclipse.tycho.extras + tycho-source-feature-plugin + ${tycho.extras.version} + + ${source.feature.skip} + FAIL + + + + source-feature + + source-feature + + + + + + org.eclipse.tycho + tycho-p2-plugin + ${tycho.version} + + + + + default-p2-metadata-default + + false + + + + + attach-p2-metadata + package + + p2-metadata + + + + + + + +
diff --git a/releng/org.eclipse.trace4cps.target/org.eclipse.trace4cps.target.target b/releng/org.eclipse.trace4cps.target/org.eclipse.trace4cps.target.target index ef5e18a2140d5cdc94fd04c38594fbadad9d5f8a..1210d16634655af43964e9608af1bab103e72a9a 100644 --- a/releng/org.eclipse.trace4cps.target/org.eclipse.trace4cps.target.target +++ b/releng/org.eclipse.trace4cps.target/org.eclipse.trace4cps.target.target @@ -1,6 +1,6 @@ - + @@ -34,14 +34,11 @@ - - - @@ -49,14 +46,11 @@ - - - diff --git a/temporallogic/org.eclipse.trace4cps.tl.cmd/.checkstyle b/temporallogic/org.eclipse.trace4cps.tl.cmd/.checkstyle new file mode 100644 index 0000000000000000000000000000000000000000..b01fc54c7363d48a5fce265944ff35f3519d22f6 --- /dev/null +++ b/temporallogic/org.eclipse.trace4cps.tl.cmd/.checkstyle @@ -0,0 +1,7 @@ + + + + + + + diff --git a/temporallogic/org.eclipse.trace4cps.tl.cmd/.project b/temporallogic/org.eclipse.trace4cps.tl.cmd/.project index e017f194dce750324ea15502753d791aad861bff..fe43c767c499ca24d1342622f9dd2acc3986ef19 100644 --- a/temporallogic/org.eclipse.trace4cps.tl.cmd/.project +++ b/temporallogic/org.eclipse.trace4cps.tl.cmd/.project @@ -10,8 +10,14 @@ + + net.sf.eclipsecs.core.CheckstyleBuilder + + + org.eclipse.jdt.core.javanature + net.sf.eclipsecs.core.CheckstyleNature diff --git a/temporallogic/org.eclipse.trace4cps.tl.cmd/pom.xml b/temporallogic/org.eclipse.trace4cps.tl.cmd/pom.xml index f4c136d1613bf13b16d52684367f465103f0d79d..c9e4de7bdf7af95762a2bcfaea5c14169628b1e7 100644 --- a/temporallogic/org.eclipse.trace4cps.tl.cmd/pom.xml +++ b/temporallogic/org.eclipse.trace4cps.tl.cmd/pom.xml @@ -19,11 +19,11 @@ 0.1.0-SNAPSHOT ../../ - + TRACE4CPS Runtime Verification CLI org.eclipse.trace4cps.tl.cmd jar - + junit @@ -76,9 +76,11 @@ ${project.build.directory}/lib - - + system runtime diff --git a/temporallogic/org.eclipse.trace4cps.tl.cmd/src/main/java/org/eclipse/trace4cps/tl/cmd/Verify.java b/temporallogic/org.eclipse.trace4cps.tl.cmd/src/main/java/org/eclipse/trace4cps/tl/cmd/Verify.java index f6e90aa9392423b2300cdc559b701ed7241ef016..5e036c6159beff54c6c47e9f1e284ecbf0543b18 100644 --- a/temporallogic/org.eclipse.trace4cps.tl.cmd/src/main/java/org/eclipse/trace4cps/tl/cmd/Verify.java +++ b/temporallogic/org.eclipse.trace4cps.tl.cmd/src/main/java/org/eclipse/trace4cps/tl/cmd/Verify.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.tl.cmd; import java.io.File; @@ -39,7 +40,6 @@ import com.google.inject.Injector; import com.google.inject.Provider; public class Verify { - @Inject private Provider resourceSetProvider; @@ -59,7 +59,6 @@ public class Verify { // We have this method for JUnit testing (we don't want to call System.exit during unit tests) public static int doMain(String[] args) { - if (args.length != 2) { showUsage(); return exitError("Please provide the proper arguments."); @@ -95,18 +94,19 @@ public class Verify { } /** - * @return 0 iff all properties satisfied, n>0 iff n properties not satisfied, <0 iff syntax error or - * validation error in spec file + * @return 0 iff all properties satisfied, n>0 iff n properties not satisfied, <0 iff syntax error or validation + * error in spec file */ - private int run(File specFile, File traceFile) throws FormulaBuilderException, InterruptedException, - ExecutionException, ParseException, IOException { + private int run(File specFile, File traceFile) + throws FormulaBuilderException, InterruptedException, ExecutionException, ParseException, IOException + { ITrace trace = TraceReader.readTrace(traceFile); Resource resource = getValidatedResource(specFile.getAbsolutePath()); if (resource == null) { return -1; // syntax errors or validation errors in given model } - EtlModel model = (EtlModel) resource.getContents().get(0); + EtlModel model = (EtlModel)resource.getContents().get(0); VerificationHelper vh = new VerificationHelper(trace, model); return printResult(vh.run()); @@ -116,10 +116,9 @@ public class Verify { ResourceSet resourceSet = resourceSetProvider.get(); Resource resource = resourceSet.getResource(URI.createFileURI(filename), true); // Validation - IResourceValidator validator = - ((XtextResource) resource).getResourceServiceProvider().getResourceValidator(); + IResourceValidator validator = ((XtextResource)resource).getResourceServiceProvider().getResourceValidator(); List issues = validator.validate(resource, CheckMode.ALL, CancelIndicator.NullImpl); - for (Issue issue : issues) { + for (Issue issue: issues) { if (issue.getSeverity() == Severity.ERROR) { return null; } @@ -132,7 +131,7 @@ public class Verify { */ private int printResult(VerificationResult verRes) { int unsatCount = 0; - for (MtlFormula phi : verRes.getChecks()) { + for (MtlFormula phi: verRes.getChecks()) { String index = ""; if (verRes.isQuantifiedCheck(phi)) { index = "[" + verRes.getQuantifierValue(phi) + "]"; diff --git a/temporallogic/org.eclipse.trace4cps.tl.cmd/src/test/java/org/eclipse/trace4cps/tl/cmd/test/VerifyTest.java b/temporallogic/org.eclipse.trace4cps.tl.cmd/src/test/java/org/eclipse/trace4cps/tl/cmd/test/VerifyTest.java index 5702a60c2e43c100b9651093591bc4ef7d3b4a7b..2c34cd2d7a066f1d14e0236039b3aab5de0b3e61 100644 --- a/temporallogic/org.eclipse.trace4cps.tl.cmd/src/test/java/org/eclipse/trace4cps/tl/cmd/test/VerifyTest.java +++ b/temporallogic/org.eclipse.trace4cps.tl.cmd/src/test/java/org/eclipse/trace4cps/tl/cmd/test/VerifyTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.tl.cmd.test; import static org.junit.Assert.assertEquals; @@ -17,13 +18,12 @@ import org.eclipse.trace4cps.tl.cmd.Verify; import org.junit.Test; public class VerifyTest { - @Test public void testMain0() { int exitCode = verify("./src/test/resources/spec0.etl", "./src/test/resources/trace.etf"); assertEquals(0, exitCode); } - + @Test public void testMain1() { int exitCode = verify("./src/test/resources/spec1.etl", "./src/test/resources/trace.etf"); diff --git a/temporallogic/org.eclipse.trace4cps.tl.ide/.checkstyle b/temporallogic/org.eclipse.trace4cps.tl.ide/.checkstyle new file mode 100644 index 0000000000000000000000000000000000000000..2457f25d4607cc7e0697c8779a1efe5ba231961e --- /dev/null +++ b/temporallogic/org.eclipse.trace4cps.tl.ide/.checkstyle @@ -0,0 +1,7 @@ + + + + + + + diff --git a/temporallogic/org.eclipse.trace4cps.tl.ide/.project b/temporallogic/org.eclipse.trace4cps.tl.ide/.project index 5dc6342082e9e3aee4234ae63519c2313ac5b488..63d119893af74b68187d5ae7c53f1205960a294e 100644 --- a/temporallogic/org.eclipse.trace4cps.tl.ide/.project +++ b/temporallogic/org.eclipse.trace4cps.tl.ide/.project @@ -30,11 +30,17 @@ + + net.sf.eclipsecs.core.CheckstyleBuilder + + + org.eclipse.m2e.core.maven2Nature org.eclipse.xtext.ui.shared.xtextNature org.eclipse.jdt.core.javanature org.eclipse.pde.PluginNature + net.sf.eclipsecs.core.CheckstyleNature diff --git a/temporallogic/org.eclipse.trace4cps.tl.ide/src/org/eclipse/trace4cps/tl/ide/EtlIdeModule.java b/temporallogic/org.eclipse.trace4cps.tl.ide/src/org/eclipse/trace4cps/tl/ide/EtlIdeModule.java index 539217520e44b9fc0a467c88a77af4dd7a140db6..402cd56f7cf7ab92da2a59549ec985470f22396f 100644 --- a/temporallogic/org.eclipse.trace4cps.tl.ide/src/org/eclipse/trace4cps/tl/ide/EtlIdeModule.java +++ b/temporallogic/org.eclipse.trace4cps.tl.ide/src/org/eclipse/trace4cps/tl/ide/EtlIdeModule.java @@ -10,8 +10,8 @@ /* * generated by Xtext 2.22.0 */ -package org.eclipse.trace4cps.tl.ide; +package org.eclipse.trace4cps.tl.ide; /** * Use this class to register ide components. diff --git a/temporallogic/org.eclipse.trace4cps.tl.ide/src/org/eclipse/trace4cps/tl/ide/EtlIdeSetup.java b/temporallogic/org.eclipse.trace4cps.tl.ide/src/org/eclipse/trace4cps/tl/ide/EtlIdeSetup.java index 0e0f123de8b67cfef0c472d58fd81884cf344cd4..b7c13583094bf069b12f5b2da301cb3ee2f6ca0c 100644 --- a/temporallogic/org.eclipse.trace4cps.tl.ide/src/org/eclipse/trace4cps/tl/ide/EtlIdeSetup.java +++ b/temporallogic/org.eclipse.trace4cps.tl.ide/src/org/eclipse/trace4cps/tl/ide/EtlIdeSetup.java @@ -10,22 +10,22 @@ /* * generated by Xtext 2.22.0 */ + package org.eclipse.trace4cps.tl.ide; -import com.google.inject.Guice; -import com.google.inject.Injector; import org.eclipse.trace4cps.tl.EtlRuntimeModule; import org.eclipse.trace4cps.tl.EtlStandaloneSetup; import org.eclipse.xtext.util.Modules2; +import com.google.inject.Guice; +import com.google.inject.Injector; + /** * Initialization support for running Xtext languages as language servers. */ public class EtlIdeSetup extends EtlStandaloneSetup { - - @Override - public Injector createInjector() { - return Guice.createInjector(Modules2.mixin(new EtlRuntimeModule(), new EtlIdeModule())); - } - + @Override + public Injector createInjector() { + return Guice.createInjector(Modules2.mixin(new EtlRuntimeModule(), new EtlIdeModule())); + } } diff --git a/temporallogic/org.eclipse.trace4cps.tl.tests/.checkstyle b/temporallogic/org.eclipse.trace4cps.tl.tests/.checkstyle new file mode 100644 index 0000000000000000000000000000000000000000..2457f25d4607cc7e0697c8779a1efe5ba231961e --- /dev/null +++ b/temporallogic/org.eclipse.trace4cps.tl.tests/.checkstyle @@ -0,0 +1,7 @@ + + + + + + + diff --git a/temporallogic/org.eclipse.trace4cps.tl.tests/.project b/temporallogic/org.eclipse.trace4cps.tl.tests/.project index a887ca01df7122c4b106863ed69d3a7997172df4..6fbd777e2a0877b6a9d06db43578d75b7cd9364f 100644 --- a/temporallogic/org.eclipse.trace4cps.tl.tests/.project +++ b/temporallogic/org.eclipse.trace4cps.tl.tests/.project @@ -30,11 +30,17 @@ + + net.sf.eclipsecs.core.CheckstyleBuilder + + + org.eclipse.m2e.core.maven2Nature org.eclipse.xtext.ui.shared.xtextNature org.eclipse.jdt.core.javanature org.eclipse.pde.PluginNature + net.sf.eclipsecs.core.CheckstyleNature diff --git a/temporallogic/org.eclipse.trace4cps.tl.tests/src/org/eclipse/trace4cps/tl/tests/CycleDetectorTest.java b/temporallogic/org.eclipse.trace4cps.tl.tests/src/org/eclipse/trace4cps/tl/tests/CycleDetectorTest.java index 6f646f6411a432a46161e7a02bb434e878ee9f4f..97bbdf3606f1e14b391335365133e01be977d87d 100644 --- a/temporallogic/org.eclipse.trace4cps.tl.tests/src/org/eclipse/trace4cps/tl/tests/CycleDetectorTest.java +++ b/temporallogic/org.eclipse.trace4cps.tl.tests/src/org/eclipse/trace4cps/tl/tests/CycleDetectorTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.tl.tests; import org.eclipse.trace4cps.tl.validation.CycleDetector; @@ -14,7 +15,6 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; public class CycleDetectorTest { - @Test public void testSimpleCycle() { CycleDetector d = new CycleDetector(); diff --git a/temporallogic/org.eclipse.trace4cps.tl.ui/.checkstyle b/temporallogic/org.eclipse.trace4cps.tl.ui/.checkstyle new file mode 100644 index 0000000000000000000000000000000000000000..2457f25d4607cc7e0697c8779a1efe5ba231961e --- /dev/null +++ b/temporallogic/org.eclipse.trace4cps.tl.ui/.checkstyle @@ -0,0 +1,7 @@ + + + + + + + diff --git a/temporallogic/org.eclipse.trace4cps.tl.ui/.project b/temporallogic/org.eclipse.trace4cps.tl.ui/.project index 1eca57a814dd62d7c72111b0d8e2c77502b9c7fe..15ef0185208ac96f36c454e51f5fcedc56d05b66 100644 --- a/temporallogic/org.eclipse.trace4cps.tl.ui/.project +++ b/temporallogic/org.eclipse.trace4cps.tl.ui/.project @@ -30,11 +30,17 @@ + + net.sf.eclipsecs.core.CheckstyleBuilder + + + org.eclipse.m2e.core.maven2Nature org.eclipse.xtext.ui.shared.xtextNature org.eclipse.jdt.core.javanature org.eclipse.pde.PluginNature + net.sf.eclipsecs.core.CheckstyleNature diff --git a/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/EtlUiModule.java b/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/EtlUiModule.java index 514021b2e009d0785b29de74aaed381adec1e460..7c89473aebac6e56ef6f8c069d0c3262b12b65fe 100644 --- a/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/EtlUiModule.java +++ b/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/EtlUiModule.java @@ -10,6 +10,7 @@ /* * generated by Xtext 2.21.0 */ + package org.eclipse.trace4cps.tl.ui; import org.eclipse.trace4cps.tl.ui.autoedit.EtlAutoEditStrategyProvider; @@ -20,7 +21,6 @@ import org.eclipse.xtext.ui.editor.autoedit.AbstractEditStrategyProvider; * Use this class to register components to be used within the Eclipse IDE. */ public class EtlUiModule extends AbstractEtlUiModule { - public EtlUiModule(AbstractUIPlugin plugin) { super(plugin); } diff --git a/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/Util.java b/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/Util.java index bb9550d7407af8ab7d9162df0dc2c91fd9d13e33..4cbe64b0687727e8de094e85b86c227299c92344 100644 --- a/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/Util.java +++ b/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/Util.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.tl.ui; import java.net.URI; @@ -32,7 +33,6 @@ import org.eclipse.ui.model.WorkbenchLabelProvider; import org.eclipse.ui.views.navigator.ResourceComparator; public class Util { - private Util() { } @@ -53,20 +53,19 @@ public class Util { } private static List browseForFilesInWorkspace(Shell parent, String[] ext, boolean allowMultiple) { - ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(parent, - new WorkbenchLabelProvider(), new WorkbenchContentProvider()); + ElementTreeSelectionDialog dialog = new ElementTreeSelectionDialog(parent, new WorkbenchLabelProvider(), + new WorkbenchContentProvider()); dialog.setTitle("Select file"); dialog.setInput(ResourcesPlugin.getWorkspace().getRoot()); dialog.setComparator(new ResourceComparator(ResourceComparator.NAME)); dialog.setAllowMultiple(allowMultiple); if (ext != null && ext.length > 0) { dialog.addFilter(new ViewerFilter() { - @Override public boolean select(Viewer viewer, Object parent, Object element) { if (element instanceof IFile) { - IFile f = (IFile) element; - for (String extension : ext) { + IFile f = (IFile)element; + for (String extension: ext) { if (f.getName().endsWith(extension)) { return true; } @@ -79,8 +78,8 @@ public class Util { } if (dialog.open() == IDialogConstants.OK_ID) { List result = new ArrayList<>(); - for (Object r : dialog.getResult()) { - IResource resource = (IResource) r; + for (Object r: dialog.getResult()) { + IResource resource = (IResource)r; result.add(resource.getLocation().toString()); } return result; @@ -93,7 +92,7 @@ public class Util { return null; } if (input instanceof IFileEditorInput) { - return ((IFileEditorInput) input).getFile(); + return ((IFileEditorInput)input).getFile(); } IPath path = getPathFromEditorInput(input); if (path == null) { @@ -104,10 +103,10 @@ public class Util { public static IPath getPathFromEditorInput(IEditorInput input) { if (input instanceof ILocationProvider) { - return ((ILocationProvider) input).getPath(input); + return ((ILocationProvider)input).getPath(input); } if (input instanceof IURIEditorInput) { - URI uri = ((IURIEditorInput) input).getURI(); + URI uri = ((IURIEditorInput)input).getURI(); if (uri != null) { IPath path = URIUtil.toPath(uri); if (path != null) { diff --git a/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/autoedit/EtlAutoEditStrategyProvider.java b/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/autoedit/EtlAutoEditStrategyProvider.java index 70bc5a2235674fd0e3b5f6294a11a898f252f63d..45372fb5c73952b4d149ea5cbb268ea42d8351c4 100644 --- a/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/autoedit/EtlAutoEditStrategyProvider.java +++ b/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/autoedit/EtlAutoEditStrategyProvider.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.tl.ui.autoedit; import java.util.List; @@ -18,11 +19,10 @@ import org.eclipse.xtext.ui.editor.autoedit.DefaultAutoEditStrategyProvider; import com.google.common.collect.Lists; public class EtlAutoEditStrategyProvider extends DefaultAutoEditStrategyProvider { - /** - * Just remove all strategies... I don't know how to only remove auto-editing of the parentheses and - * square brackets (for the time intervals). - * + * Just remove all strategies... I don't know how to only remove auto-editing of the parentheses and square brackets + * (for the time intervals). + * * {@inheritDoc} */ @Override diff --git a/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/contentassist/EtlProposalProvider.java b/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/contentassist/EtlProposalProvider.java index d539d2f84ad32629cde35d072d3b416620a19d1d..140fa31d4d0978691f2363b4eab178869f161db9 100644 --- a/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/contentassist/EtlProposalProvider.java +++ b/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/contentassist/EtlProposalProvider.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.tl.ui.contentassist; import org.eclipse.emf.ecore.EObject; @@ -21,14 +22,14 @@ import org.eclipse.xtext.ui.editor.contentassist.ContentAssistContext; import org.eclipse.xtext.ui.editor.contentassist.ICompletionProposalAcceptor; /** - * See https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#content-assist on how to customize - * the content assistant. + * See https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#content-assist on how to customize the + * content assistant. */ public class EtlProposalProvider extends AbstractEtlProposalProvider { - @Override public void completeKeyword(Keyword keyword, ContentAssistContext contentAssistContext, - ICompletionProposalAcceptor acceptor) { + ICompletionProposalAcceptor acceptor) + { } // // @Override @@ -47,69 +48,80 @@ public class EtlProposalProvider extends AbstractEtlProposalProvider { @Override public void complete_AttributeFilter(EObject model, RuleCall ruleCall, ContentAssistContext context, - ICompletionProposalAcceptor acceptor) { + ICompletionProposalAcceptor acceptor) + { acceptor.accept(createCompletionProposal("{'name'='', ...}", context)); } @Override public void complete_StlAp(EObject model, RuleCall ruleCall, ContentAssistContext context, - ICompletionProposalAcceptor acceptor) { + ICompletionProposalAcceptor acceptor) + { EtlModel m = FormulaHelper.findContainer(model, EtlModelImpl.class); - for (SignalDef signalEl : FormulaBuilder.get(m, SignalDef.class)) { + for (SignalDef signalEl: FormulaBuilder.get(m, SignalDef.class)) { acceptor.accept(createCompletionProposal(signalEl.getName() + " >= 0.0", context)); } } @Override public void complete_IntervalSS(EObject model, RuleCall ruleCall, ContentAssistContext context, - ICompletionProposalAcceptor acceptor) { + ICompletionProposalAcceptor acceptor) + { acceptor.accept(createCompletionProposal("(0.0, 1.0)", context)); } @Override public void complete_IntervalSN(EObject model, RuleCall ruleCall, ContentAssistContext context, - ICompletionProposalAcceptor acceptor) { + ICompletionProposalAcceptor acceptor) + { acceptor.accept(createCompletionProposal("(0.0, 1.0]", context)); } @Override public void complete_IntervalNS(EObject model, RuleCall ruleCall, ContentAssistContext context, - ICompletionProposalAcceptor acceptor) { + ICompletionProposalAcceptor acceptor) + { acceptor.accept(createCompletionProposal("[0.0, 1.0)", context)); } @Override public void complete_IntervalNN(EObject model, RuleCall ruleCall, ContentAssistContext context, - ICompletionProposalAcceptor acceptor) { + ICompletionProposalAcceptor acceptor) + { acceptor.accept(createCompletionProposal("[0.0, 1.0]", context)); } @Override public void complete_TimeUnitEnum(EObject model, RuleCall ruleCall, ContentAssistContext context, - ICompletionProposalAcceptor acceptor) { + ICompletionProposalAcceptor acceptor) + { acceptor.accept(createCompletionProposal("ns|us|ms|s|min|hr", context)); } @Override public void complete_INT_T(EObject model, RuleCall ruleCall, ContentAssistContext context, - ICompletionProposalAcceptor acceptor) { + ICompletionProposalAcceptor acceptor) + { acceptor.accept(createCompletionProposal("0", context)); } @Override public void complete_DOUBLE_T(EObject model, RuleCall ruleCall, ContentAssistContext context, - ICompletionProposalAcceptor acceptor) { + ICompletionProposalAcceptor acceptor) + { acceptor.accept(createCompletionProposal("0.0", context)); } @Override public void complete_Signal(EObject model, RuleCall ruleCall, ContentAssistContext context, - ICompletionProposalAcceptor acceptor) { + ICompletionProposalAcceptor acceptor) + { acceptor.accept(createCompletionProposal("signal ID : ", context)); } public void complete_ConvSpec(EObject model, RuleCall ruleCall, ContentAssistContext context, - ICompletionProposalAcceptor acceptor) { + ICompletionProposalAcceptor acceptor) + { acceptor.accept(createCompletionProposal("over 10.0 ms", context)); } // @@ -169,26 +181,31 @@ public class EtlProposalProvider extends AbstractEtlProposalProvider { @Override public void complete_EtlModel(EObject model, RuleCall ruleCall, ContentAssistContext context, - ICompletionProposalAcceptor acceptor) { + ICompletionProposalAcceptor acceptor) + { } @Override public void complete_Formula(EObject model, RuleCall ruleCall, ContentAssistContext context, - ICompletionProposalAcceptor acceptor) { + ICompletionProposalAcceptor acceptor) + { } @Override public void complete_KeyVal(EObject model, RuleCall ruleCall, ContentAssistContext context, - ICompletionProposalAcceptor acceptor) { + ICompletionProposalAcceptor acceptor) + { } @Override public void complete_IdString(EObject model, RuleCall ruleCall, ContentAssistContext context, - ICompletionProposalAcceptor acceptor) { + ICompletionProposalAcceptor acceptor) + { } @Override public void complete_Interval(EObject model, RuleCall ruleCall, ContentAssistContext context, - ICompletionProposalAcceptor acceptor) { + ICompletionProposalAcceptor acceptor) + { } } diff --git a/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/labeling/EtlDescriptionLabelProvider.java b/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/labeling/EtlDescriptionLabelProvider.java index c84e864e7446a5a6ef2b8e0efefbe92bdc1f769d..ae4aede05bf8d6f68f371d0a9f70e7727a0f2b8c 100644 --- a/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/labeling/EtlDescriptionLabelProvider.java +++ b/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/labeling/EtlDescriptionLabelProvider.java @@ -7,26 +7,27 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.tl.ui.labeling; import org.eclipse.xtext.ui.label.DefaultDescriptionLabelProvider; /** * Provides labels for IEObjectDescriptions and IResourceDescriptions. - * + *

* See https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#label-provider + *

*/ public class EtlDescriptionLabelProvider extends DefaultDescriptionLabelProvider { - - // Labels and icons can be computed like this: -// @Override -// public String text(IEObjectDescription ele) { -// return ele.getName().toString(); -// } -// -// @Override -// public String image(IEObjectDescription ele) { -// return ele.getEClass().getName() + ".gif"; -// } + // Labels and icons can be computed like this: +// @Override +// public String text(IEObjectDescription ele) { +// return ele.getName().toString(); +// } +// +// @Override +// public String image(IEObjectDescription ele) { +// return ele.getEClass().getName() + ".gif"; +// } } diff --git a/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/labeling/EtlLabelProvider.java b/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/labeling/EtlLabelProvider.java index 705492960e54f5eec5775ef9ce1b7e8e09da1b3b..534f3d923c28661bc28411ba539ca7d2ce59672f 100644 --- a/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/labeling/EtlLabelProvider.java +++ b/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/labeling/EtlLabelProvider.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.tl.ui.labeling; import org.eclipse.emf.edit.ui.provider.AdapterFactoryLabelProvider; @@ -46,11 +47,11 @@ import com.google.inject.Inject; /** * Provides labels for EObjects. - * + *

* See https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#label-provider + *

*/ public class EtlLabelProvider extends DefaultEObjectLabelProvider { - @Inject public EtlLabelProvider(AdapterFactoryLabelProvider delegate) { super(delegate); @@ -118,7 +119,6 @@ public class EtlLabelProvider extends DefaultEObjectLabelProvider { } } return ref.getDef().getName(); - } String text(GloballyUntimedFormula g) { diff --git a/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/outline/EtlOutlineTreeProvider.java b/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/outline/EtlOutlineTreeProvider.java index e30d8ef8cbbc5941ffaf0d914d5f17c3dbb4f250..ca9c5aa331fa0367d02af3e34230bbf83427c56e 100644 --- a/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/outline/EtlOutlineTreeProvider.java +++ b/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/outline/EtlOutlineTreeProvider.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.tl.ui.outline; import org.eclipse.trace4cps.tl.etl.ApFormula; @@ -22,14 +23,14 @@ import org.eclipse.xtext.ui.editor.outline.impl.DefaultOutlineTreeProvider; /** * Customization of the default outline structure. - * + *

* See https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#outline + *

*/ public class EtlOutlineTreeProvider extends DefaultOutlineTreeProvider { // - private void createAttributeFilter(IOutlineNode parentNode, AttributeFilter f) { - for (KeyVal kv : f.getKeyVals()) { + for (KeyVal kv: f.getKeyVals()) { createNode(parentNode, kv); } } diff --git a/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/quickfix/EtlQuickfixProvider.java b/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/quickfix/EtlQuickfixProvider.java index d0e7f83275dbcf5a8e757d55180e2dbe110f9f88..a6b3f5577d2fc92f8f9f86c3bcdbf11960c2c142 100644 --- a/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/quickfix/EtlQuickfixProvider.java +++ b/temporallogic/org.eclipse.trace4cps.tl.ui/src/org/eclipse/trace4cps/tl/ui/quickfix/EtlQuickfixProvider.java @@ -10,26 +10,27 @@ /* * generated by Xtext 2.21.0 */ + package org.eclipse.trace4cps.tl.ui.quickfix; import org.eclipse.xtext.ui.editor.quickfix.DefaultQuickfixProvider; /** * Custom quickfixes. - * + *

* See https://www.eclipse.org/Xtext/documentation/310_eclipse_support.html#quick-fixes + *

*/ public class EtlQuickfixProvider extends DefaultQuickfixProvider { -// @Fix(ETLValidator.INVALID_NAME) -// public void capitalizeName(final Issue issue, IssueResolutionAcceptor acceptor) { -// acceptor.accept(issue, "Capitalize name", "Capitalize the name.", "upcase.png", new IModification() { -// public void apply(IModificationContext context) throws BadLocationException { -// IXtextDocument xtextDocument = context.getXtextDocument(); -// String firstLetter = xtextDocument.get(issue.getOffset(), 1); -// xtextDocument.replace(issue.getOffset(), 1, firstLetter.toUpperCase()); -// } -// }); -// } - +// @Fix(ETLValidator.INVALID_NAME) +// public void capitalizeName(final Issue issue, IssueResolutionAcceptor acceptor) { +// acceptor.accept(issue, "Capitalize name", "Capitalize the name.", "upcase.png", new IModification() { +// public void apply(IModificationContext context) throws BadLocationException { +// IXtextDocument xtextDocument = context.getXtextDocument(); +// String firstLetter = xtextDocument.get(issue.getOffset(), 1); +// xtextDocument.replace(issue.getOffset(), 1, firstLetter.toUpperCase()); +// } +// }); +// } } diff --git a/temporallogic/org.eclipse.trace4cps.tl/.checkstyle b/temporallogic/org.eclipse.trace4cps.tl/.checkstyle new file mode 100644 index 0000000000000000000000000000000000000000..ce904cbeaae1f0e16e0bda27cdc860b5e1dfc385 --- /dev/null +++ b/temporallogic/org.eclipse.trace4cps.tl/.checkstyle @@ -0,0 +1,7 @@ + + + + + + + diff --git a/temporallogic/org.eclipse.trace4cps.tl/.project b/temporallogic/org.eclipse.trace4cps.tl/.project index 690eb4d851552d624929f15ea56ba74955249c06..93440d41b8f8be5b753be272642456af079375dd 100644 --- a/temporallogic/org.eclipse.trace4cps.tl/.project +++ b/temporallogic/org.eclipse.trace4cps.tl/.project @@ -30,11 +30,17 @@ + + net.sf.eclipsecs.core.CheckstyleBuilder + + + org.eclipse.m2e.core.maven2Nature org.eclipse.xtext.ui.shared.xtextNature org.eclipse.jdt.core.javanature org.eclipse.pde.PluginNature + net.sf.eclipsecs.core.CheckstyleNature diff --git a/temporallogic/org.eclipse.trace4cps.tl/META-INF/MANIFEST.MF b/temporallogic/org.eclipse.trace4cps.tl/META-INF/MANIFEST.MF index d71d8a2c70c8833ad70823500fe977835681fff7..9389f8f3300e5bd0dce11d3f36163f8d7b01d360 100644 --- a/temporallogic/org.eclipse.trace4cps.tl/META-INF/MANIFEST.MF +++ b/temporallogic/org.eclipse.trace4cps.tl/META-INF/MANIFEST.MF @@ -26,7 +26,6 @@ Export-Package: org.eclipse.trace4cps.tl, org.eclipse.trace4cps.tl.etl.impl, org.eclipse.trace4cps.tl.etl.util, org.eclipse.trace4cps.tl.formatting2, - org.eclipse.trace4cps.tl.generator, org.eclipse.trace4cps.tl.parser.antlr, org.eclipse.trace4cps.tl.parser.antlr.internal, org.eclipse.trace4cps.tl.scoping, diff --git a/temporallogic/org.eclipse.trace4cps.tl/pom.xml b/temporallogic/org.eclipse.trace4cps.tl/pom.xml index e12b260e56d5bb7af642cc72e4e795e059bc4bb7..a6443ad9e096fca224079ea1054c361deca772b4 100644 --- a/temporallogic/org.eclipse.trace4cps.tl/pom.xml +++ b/temporallogic/org.eclipse.trace4cps.tl/pom.xml @@ -10,8 +10,8 @@ --> - 4.0.0 + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> + 4.0.0 org.eclipse.trace4cps @@ -19,162 +19,165 @@ 0.1.0-SNAPSHOT ../../ - - TRACE4CPS Runtime Verification - org.eclipse.trace4cps.tl - eclipse-plugin - - - - - - org.eclipse.m2e - lifecycle-mapping - 1.0.0 - - - - - - org.codehaus.mojo - exec-maven-plugin - [1.6.0,) - - java - - - - - - - - - - - - - + TRACE4CPS Runtime Verification + org.eclipse.trace4cps.tl + eclipse-plugin + + + + + + + org.eclipse.m2e + lifecycle-mapping + 1.0.0 + + + + + + org.codehaus.mojo + exec-maven-plugin + [1.6.0,) + + java + + + + + + + + + + + + + - - mwe2Launcher - - true - - - - - org.codehaus.mojo - exec-maven-plugin - 1.6.0 - - - mwe2Launcher - generate-sources - - java - - - - - org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher - - /${project.basedir}/src/org/eclipse/trace4cps/tl/GenerateETL.mwe2 - -p - rootPath=/${project.basedir}/.. - - compile - true - false - - - - org.eclipse.emf - org.eclipse.emf.mwe2.launch - ${mwe2.version} - - - org.eclipse.xtext - org.eclipse.xtext.common.types - ${xtext.version} - - - org.eclipse.xtext - org.eclipse.xtext.xtext.generator - ${xtext.version} - - - org.eclipse.platform - org.eclipse.equinox.common - - - org.eclipse.platform - org.eclipse.core.runtime - - - - - org.eclipse.xtext - org.eclipse.xtext.xbase - ${xtext.version} - - - org.eclipse.xtext - xtext-antlr-generator - 2.1.1 - - - - - - org.eclipse.xtend - xtend-maven-plugin - - - - org.apache.maven.plugins - maven-clean-plugin - - - - ${basedir}/../org.eclipse.trace4cps.tl/src-gen/ - - **/* - - - - ${basedir}/../org.eclipse.trace4cps.tl.tests/src-gen/ - - **/* - - - - ${basedir}/../org.eclipse.trace4cps.tl.ide/src-gen/ - - **/* - - - - ${basedir}/../org.eclipse.trace4cps.tl.ui/src-gen/ - - **/* - - - - ${basedir}/../org.eclipse.trace4cps.tl.ui.tests/src-gen/ - - **/* - - - - ${basedir}/model/generated/ - - - - - - - - + + mwe2Launcher + + true + + + + + org.codehaus.mojo + exec-maven-plugin + 1.6.0 + + + mwe2Launcher + generate-sources + + java + + + + + org.eclipse.emf.mwe2.launch.runtime.Mwe2Launcher + + /${project.basedir}/src/org/eclipse/trace4cps/tl/GenerateETL.mwe2 + -p + rootPath=/${project.basedir}/.. + + compile + true + false + + + + org.eclipse.emf + org.eclipse.emf.mwe2.launch + ${mwe2.version} + + + org.eclipse.xtext + org.eclipse.xtext.common.types + ${xtext.version} + + + org.eclipse.xtext + org.eclipse.xtext.xtext.generator + ${xtext.version} + + + org.eclipse.platform + org.eclipse.equinox.common + + + org.eclipse.platform + org.eclipse.core.runtime + + + + + org.eclipse.xtext + org.eclipse.xtext.xbase + ${xtext.version} + + + org.eclipse.xtext + xtext-antlr-generator + 2.1.1 + + + + + + org.eclipse.xtend + xtend-maven-plugin + + + + org.apache.maven.plugins + maven-clean-plugin + + + + ${basedir}/../org.eclipse.trace4cps.tl/src-gen/ + + **/* + + + + ${basedir}/../org.eclipse.trace4cps.tl.tests/src-gen/ + + **/* + + + + ${basedir}/../org.eclipse.trace4cps.tl.ide/src-gen/ + + **/* + + + + ${basedir}/../org.eclipse.trace4cps.tl.ui/src-gen/ + + **/* + + + + ${basedir}/../org.eclipse.trace4cps.tl.ui.tests/src-gen/ + + **/* + + + + ${basedir}/model/generated/ + + + + + + + + diff --git a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/EtlRuntimeModule.java b/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/EtlRuntimeModule.java index 93b3a594e3289c710fdeb00d4dea30c1099865cf..6203473e5d55089bba1b0b0727942b92ab2cf178 100644 --- a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/EtlRuntimeModule.java +++ b/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/EtlRuntimeModule.java @@ -7,8 +7,8 @@ * * SPDX-License-Identifier: EPL-2.0 */ -package org.eclipse.trace4cps.tl; +package org.eclipse.trace4cps.tl; /** * Use this class to register components to be used at runtime / without the Equinox extension registry. diff --git a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/EtlStandaloneSetup.java b/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/EtlStandaloneSetup.java index cd086c4151a2597dc11b29d2ecc8ac201fa6e2e7..f9a488e7065e4bd07c796989bafdfc8c9dcac5d3 100644 --- a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/EtlStandaloneSetup.java +++ b/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/EtlStandaloneSetup.java @@ -7,14 +7,14 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.tl; /** * Initialization support for running Xtext languages without Equinox extension registry. */ public class EtlStandaloneSetup extends EtlStandaloneSetupGenerated { - - public static void doSetup() { - new EtlStandaloneSetup().createInjectorAndDoEMFRegistration(); - } + public static void doSetup() { + new EtlStandaloneSetup().createInjectorAndDoEMFRegistration(); + } } diff --git a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/FormulaBuilder.java b/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/FormulaBuilder.java index 3cd41db9c84dcb4c91c2b1b83b7388335c7099de..457af7abeb79dcbea387c6f9ec7a70fbf07393ab 100644 --- a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/FormulaBuilder.java +++ b/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/FormulaBuilder.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.tl; import java.util.ArrayList; @@ -53,11 +54,10 @@ import org.eclipse.trace4cps.tl.etl.UntilFormula; import org.eclipse.trace4cps.tl.etl.UntilUntimedFormula; /** - * This type is responsible from converting a specification in the DSL to a set of {@link MtlFormula} - * instances. These are stored in the returned {@link VerificationResult}. + * This type is responsible from converting a specification in the DSL to a set of {@link MtlFormula} instances. These + * are stored in the returned {@link VerificationResult}. */ public class FormulaBuilder { - private final ITrace trace; private final EtlModel m; @@ -66,8 +66,7 @@ public class FormulaBuilder { private final Map signalMap; - public FormulaBuilder(ITrace trace, Map signalMap, EtlModel m) - throws FormulaBuilderException { + public FormulaBuilder(ITrace trace, Map signalMap, EtlModel m) throws FormulaBuilderException { this.trace = trace; this.m = m; this.result = new VerificationResult(); @@ -76,21 +75,21 @@ public class FormulaBuilder { public static List get(EtlModel model, Class clazz) { List r = new ArrayList<>(); - for (TopLevelModelElement e : model.getElements()) { + for (TopLevelModelElement e: model.getElements()) { if (clazz.isAssignableFrom(e.getClass())) { - r.add((T) e); + r.add(clazz.cast(e)); } } return r; } /** - * Creates a {@link VerificationResult} instance that contains the MTL formulas from the specification - * given on construction. It distinguishes signals, defs and checks. The result of the verification itself - * is not filled in yet. + * Creates a {@link VerificationResult} instance that contains the MTL formulas from the specification given on + * construction. It distinguishes signals, defs and checks. The result of the verification itself is not filled in + * yet. */ public VerificationResult create() throws FormulaBuilderException { - for (Check chk : get(m, Check.class)) { + for (Check chk: get(m, Check.class)) { String name = chk.getName(); if (chk.getVar() != null) { for (int i = chk.getLb(); i <= chk.getUb(); i++) { @@ -107,7 +106,7 @@ public class FormulaBuilder { public static Map toMap(AttributeFilter kvs, Integer i) { Map filter = new HashMap(); - for (KeyVal kv : kvs.getKeyVals()) { + for (KeyVal kv: kvs.getKeyVals()) { filter.put(getIdString(kv.getAtt(), i), getIdString(kv.getVal(), i)); } return filter; @@ -129,56 +128,60 @@ public class FormulaBuilder { /** * Only works for non-parameterized formulas! - * + * */ public static MtlFormula create(Formula f, ITrace trace, List signalDefs) - throws FormulaBuilderException { + throws FormulaBuilderException + { Map signalMap = FormulaHelper.createSignalMap(trace, signalDefs, true); return create(f, null, trace.getTimeUnit(), signalMap, null); } public static MtlFormula create(Formula f, Integer qValue, TimeUnit traceTu, Map signalMap, - VerificationResult result) throws FormulaBuilderException { + VerificationResult result) throws FormulaBuilderException + { if (f instanceof ReferenceFormula) { - return createRef((ReferenceFormula) f, qValue, traceTu, signalMap, result); + return createRef((ReferenceFormula)f, qValue, traceTu, signalMap, result); } else if (f instanceof ApFormula) { - return createAp((ApFormula) f, qValue, traceTu, signalMap, result); + return createAp((ApFormula)f, qValue, traceTu, signalMap, result); } else if (f instanceof AndOrFormula) { - return createAndOr((AndOrFormula) f, qValue, traceTu, signalMap, result); + return createAndOr((AndOrFormula)f, qValue, traceTu, signalMap, result); } else if (f instanceof IfThenFormula) { - return createImply((IfThenFormula) f, qValue, traceTu, signalMap, result); + return createImply((IfThenFormula)f, qValue, traceTu, signalMap, result); } else if (f instanceof NotFormula) { - return createNot((NotFormula) f, qValue, traceTu, signalMap, result); + return createNot((NotFormula)f, qValue, traceTu, signalMap, result); } else if (f instanceof FinallyUntimedFormula) { - return createF0((FinallyUntimedFormula) f, qValue, traceTu, signalMap, result); + return createF0((FinallyUntimedFormula)f, qValue, traceTu, signalMap, result); } else if (f instanceof FinallyFormula) { - return createF1((FinallyFormula) f, qValue, traceTu, signalMap, result); + return createF1((FinallyFormula)f, qValue, traceTu, signalMap, result); } else if (f instanceof GloballyUntimedFormula) { - return createG0((GloballyUntimedFormula) f, qValue, traceTu, signalMap, result); + return createG0((GloballyUntimedFormula)f, qValue, traceTu, signalMap, result); } else if (f instanceof GloballyFormula) { - return createG1((GloballyFormula) f, qValue, traceTu, signalMap, result); + return createG1((GloballyFormula)f, qValue, traceTu, signalMap, result); } else if (f instanceof UntilUntimedFormula) { - return createU0((UntilUntimedFormula) f, qValue, traceTu, signalMap, result); + return createU0((UntilUntimedFormula)f, qValue, traceTu, signalMap, result); } else if (f instanceof UntilFormula) { - return createU1((UntilFormula) f, qValue, traceTu, signalMap, result); + return createU1((UntilFormula)f, qValue, traceTu, signalMap, result); } throw new IllegalStateException("Failed to create formula for " + f); } private static MtlFormula createAndOr(AndOrFormula ao, Integer qValue, TimeUnit traceTu, - Map signalMap, VerificationResult result) throws FormulaBuilderException { + Map signalMap, VerificationResult result) throws FormulaBuilderException + { switch (ao.getOp()) { - case AND: - return createAnd(ao, qValue, traceTu, signalMap, result); - case OR: - return createOr(ao, qValue, traceTu, signalMap, result); - default: - throw new IllegalStateException(); + case AND: + return createAnd(ao, qValue, traceTu, signalMap, result); + case OR: + return createOr(ao, qValue, traceTu, signalMap, result); + default: + throw new IllegalStateException(); } } - private static MtlFormula createAp(ApFormula ap, Integer qValue, TimeUnit traceTu, - Map signalMap, VerificationResult result) throws FormulaBuilderException { + private static MtlFormula createAp(ApFormula ap, Integer qValue, TimeUnit traceTu, Map signalMap, + VerificationResult result) throws FormulaBuilderException + { if (ap.getMtlAP() != null) { return createMTL(ap.getMtlAP(), qValue); } else { @@ -187,11 +190,12 @@ public class FormulaBuilder { } private static MtlFormula createRef(ReferenceFormula f, Integer qValue, TimeUnit traceTu, - Map signalMap, VerificationResult result) throws FormulaBuilderException { + Map signalMap, VerificationResult result) throws FormulaBuilderException + { Def def = f.getDef(); int addend = f.getVal(); - MtlFormula defFormula = - create(def.getFormula(), qValue == null ? null : qValue + addend, traceTu, signalMap, result); + MtlFormula defFormula = create(def.getFormula(), qValue == null ? null : qValue + addend, traceTu, signalMap, + result); String name = def.getName(); if (qValue != null) { name += "(" + (qValue + addend) + ")"; @@ -205,7 +209,7 @@ public class FormulaBuilder { private static AtomicProposition createMTL(MtlAp f, Integer qValue) throws FormulaBuilderException { Map props = new HashMap(); AttributeFilter keyVals = f.getFilter(); - for (KeyVal kv : keyVals.getKeyVals()) { + for (KeyVal kv: keyVals.getKeyVals()) { props.put(getIdString(kv.getAtt(), qValue), getIdString(kv.getVal(), qValue)); } if (f instanceof MtlApStart) { @@ -218,119 +222,130 @@ public class FormulaBuilder { } private static MtlFormula createSTL(StlAp f, Integer qValue, TimeUnit traceTu, Map signalMap, - VerificationResult result) throws FormulaBuilderException { + VerificationResult result) throws FormulaBuilderException + { IPsop p = signalMap.get(f.getRef().getName()); if (f instanceof StlApDeriv) { p = PsopHelper.createDerivativeOf(p); } double val = f.getVal(); switch (f.getCompOp()) { - case EQ: - return StlBuilder.EQ(p, val); - case GE: - return StlBuilder.GEQ(p, val); - case LE: - return StlBuilder.LEQ(p, val); - default: - throw new IllegalStateException(); + case EQ: + return StlBuilder.EQ(p, val); + case GE: + return StlBuilder.GEQ(p, val); + case LE: + return StlBuilder.LEQ(p, val); + default: + throw new IllegalStateException(); } } - private static MtlFormula createAnd(AndOrFormula f, Integer qValue, TimeUnit traceTu, - Map signalMap, VerificationResult result) throws FormulaBuilderException { + private static MtlFormula createAnd(AndOrFormula f, Integer qValue, TimeUnit traceTu, Map signalMap, + VerificationResult result) throws FormulaBuilderException + { MtlFormula l = create(f.getLeft(), qValue, traceTu, signalMap, result); MtlFormula r = create(f.getRight(), qValue, traceTu, signalMap, result); if (l instanceof StlFormula && r instanceof StlFormula) { - return StlBuilder.AND((StlFormula) l, (StlFormula) r); + return StlBuilder.AND((StlFormula)l, (StlFormula)r); } else { return MtlBuilder.AND(l, r); } } - private static MtlFormula createOr(AndOrFormula f, Integer qValue, TimeUnit traceTu, - Map signalMap, VerificationResult result) throws FormulaBuilderException { + private static MtlFormula createOr(AndOrFormula f, Integer qValue, TimeUnit traceTu, Map signalMap, + VerificationResult result) throws FormulaBuilderException + { MtlFormula l = create(f.getLeft(), qValue, traceTu, signalMap, result); MtlFormula r = create(f.getRight(), qValue, traceTu, signalMap, result); if (l instanceof StlFormula && r instanceof StlFormula) { - return StlBuilder.OR((StlFormula) l, (StlFormula) r); + return StlBuilder.OR((StlFormula)l, (StlFormula)r); } else { return MtlBuilder.OR(l, r); } } private static MtlFormula createImply(IfThenFormula f, Integer qValue, TimeUnit traceTu, - Map signalMap, VerificationResult result) throws FormulaBuilderException { + Map signalMap, VerificationResult result) throws FormulaBuilderException + { MtlFormula l = create(f.getLeft(), qValue, traceTu, signalMap, result); MtlFormula r = create(f.getRight(), qValue, traceTu, signalMap, result); if (l instanceof StlFormula && r instanceof StlFormula) { - return StlBuilder.IMPLY((StlFormula) l, (StlFormula) r); + return StlBuilder.IMPLY((StlFormula)l, (StlFormula)r); } else { return MtlBuilder.IMPLY(l, r); } } - private static MtlFormula createNot(NotFormula f, Integer qValue, TimeUnit traceTu, - Map signalMap, VerificationResult result) throws FormulaBuilderException { + private static MtlFormula createNot(NotFormula f, Integer qValue, TimeUnit traceTu, Map signalMap, + VerificationResult result) throws FormulaBuilderException + { MtlFormula f2 = create(f.getFormula(), qValue, traceTu, signalMap, result); if (f2 instanceof StlFormula) { - return StlBuilder.NOT((StlFormula) f2); + return StlBuilder.NOT((StlFormula)f2); } else { return MtlBuilder.NOT(f2); } } private static MtlFormula createF0(FinallyUntimedFormula f, Integer qValue, TimeUnit traceTu, - Map signalMap, VerificationResult result) throws FormulaBuilderException { + Map signalMap, VerificationResult result) throws FormulaBuilderException + { MtlFormula f2 = create(f.getFormula(), qValue, traceTu, signalMap, result); if (f2 instanceof StlFormula) { - return StlBuilder.F((StlFormula) f2); + return StlBuilder.F((StlFormula)f2); } else { return MtlBuilder.F(f2); } } - private static MtlFormula createF1(FinallyFormula f, Integer qValue, TimeUnit traceTu, - Map signalMap, VerificationResult result) throws FormulaBuilderException { + private static MtlFormula createF1(FinallyFormula f, Integer qValue, TimeUnit traceTu, Map signalMap, + VerificationResult result) throws FormulaBuilderException + { MtlFormula f2 = create(f.getFormula(), qValue, traceTu, signalMap, result); Interval i = FormulaHelper.from(traceTu, f.getInterval()); if (f2 instanceof StlFormula) { - return StlBuilder.F((StlFormula) f2, i.lb().doubleValue(), i.ub().doubleValue()); + return StlBuilder.F((StlFormula)f2, i.lb().doubleValue(), i.ub().doubleValue()); } else { return MtlBuilder.F(f2, i); } } private static MtlFormula createG0(GloballyUntimedFormula f, Integer qValue, TimeUnit traceTu, - Map signalMap, VerificationResult result) throws FormulaBuilderException { + Map signalMap, VerificationResult result) throws FormulaBuilderException + { MtlFormula f2 = create(f.getFormula(), qValue, traceTu, signalMap, result); if (f2 instanceof StlFormula) { - return StlBuilder.G((StlFormula) f2); + return StlBuilder.G((StlFormula)f2); } else { return MtlBuilder.G(f2); } } private static MtlFormula createG1(GloballyFormula f, Integer qValue, TimeUnit traceTu, - Map signalMap, VerificationResult result) throws FormulaBuilderException { + Map signalMap, VerificationResult result) throws FormulaBuilderException + { MtlFormula f2 = create(f.getFormula(), qValue, traceTu, signalMap, result); Interval i = FormulaHelper.from(traceTu, f.getInterval()); if (f2 instanceof StlFormula) { - return StlBuilder.G((StlFormula) f2, i.lb().doubleValue(), i.ub().doubleValue()); + return StlBuilder.G((StlFormula)f2, i.lb().doubleValue(), i.ub().doubleValue()); } else { return MtlBuilder.G(f2, i); } } private static MtlFormula createU0(UntilUntimedFormula f, Integer qValue, TimeUnit traceTu, - Map signalMap, VerificationResult result) throws FormulaBuilderException { + Map signalMap, VerificationResult result) throws FormulaBuilderException + { MtlFormula left = create(f.getLeft(), qValue, traceTu, signalMap, result); MtlFormula right = create(f.getRight(), qValue, traceTu, signalMap, result); // general until not supported by STL algorithm return MtlBuilder.U(left, right, new Interval(0, false, Double.POSITIVE_INFINITY, true)); } - private static MtlFormula createU1(UntilFormula f, Integer qValue, TimeUnit traceTu, - Map signalMap, VerificationResult result) throws FormulaBuilderException { + private static MtlFormula createU1(UntilFormula f, Integer qValue, TimeUnit traceTu, Map signalMap, + VerificationResult result) throws FormulaBuilderException + { MtlFormula left = create(f.getLeft(), qValue, traceTu, signalMap, result); MtlFormula right = create(f.getRight(), qValue, traceTu, signalMap, result); // general until not supported by STL algorithm diff --git a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/FormulaBuilderException.java b/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/FormulaBuilderException.java index 442b051a1b28363a5ef5b2bf4849cf1d47098590..b02043bc112389c94138182bf8f162983316a46d 100644 --- a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/FormulaBuilderException.java +++ b/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/FormulaBuilderException.java @@ -7,12 +7,12 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.tl; import org.eclipse.trace4cps.core.TraceException; public class FormulaBuilderException extends TraceException { - private static final long serialVersionUID = 1L; public FormulaBuilderException() { diff --git a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/FormulaHelper.java b/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/FormulaHelper.java index f99766692f8628c41c2a7e9effb1e3aea4909a7a..f701658d6209ca4b6528f8c651811e582af6434e 100644 --- a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/FormulaHelper.java +++ b/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/FormulaHelper.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.tl; import java.util.ArrayList; @@ -60,10 +61,9 @@ import org.eclipse.trace4cps.tl.etl.UntilUntimedFormula; import org.eclipse.trace4cps.tl.etl.WipSignal; public class FormulaHelper { - public enum FormulaType { MTL, STL, MIXED - }; + } private FormulaHelper() { } @@ -72,7 +72,7 @@ public class FormulaHelper { EObject c = o.eContainer(); while (c != null) { if (clazz.isInstance(c)) { - return (T) c; + return clazz.cast(c); } c = c.eContainer(); } @@ -81,18 +81,18 @@ public class FormulaHelper { public static TimeUnit valueOf(TimeUnitEnum tu) { switch (tu) { - case NS: - return TimeUnit.NANOSECONDS; - case US: - return TimeUnit.MICROSECONDS; - case MS: - return TimeUnit.MILLISECONDS; - case S: - return TimeUnit.SECONDS; - case MIN: - return TimeUnit.MINUTES; - case HR: - return TimeUnit.HOURS; + case NS: + return TimeUnit.NANOSECONDS; + case US: + return TimeUnit.MICROSECONDS; + case MS: + return TimeUnit.MILLISECONDS; + case S: + return TimeUnit.SECONDS; + case MIN: + return TimeUnit.MINUTES; + case HR: + return TimeUnit.HOURS; } throw new IllegalArgumentException(); } @@ -102,15 +102,15 @@ public class FormulaHelper { return "[" + i.getInn().getLb() + "," + i.getInn().getUb() + "] " + i.getTimeUnit(); } if (i.getIns() != null) { - return "[" + i.getIns().getLb() + "," - + (i.getIns().getInfty() != null ? "Infty" : i.getIns().getUb()) + ") " + i.getTimeUnit(); + return "[" + i.getIns().getLb() + "," + (i.getIns().getInfty() != null ? "Infty" : i.getIns().getUb()) + + ") " + i.getTimeUnit(); } if (i.getIsn() != null) { return "(" + i.getIsn().getLb() + "," + i.getIsn().getUb() + "] " + i.getTimeUnit(); } if (i.getIss() != null) { - return "(" + i.getIss().getLb() + "," - + (i.getIss().getInfty() != null ? "Infty" : i.getIss().getUb()) + ") " + i.getTimeUnit(); + return "(" + i.getIss().getLb() + "," + (i.getIss().getInfty() != null ? "Infty" : i.getIss().getUb()) + + ") " + i.getTimeUnit(); } throw new IllegalStateException("Unexpected structure in model"); } @@ -130,9 +130,9 @@ public class FormulaHelper { } public static boolean hasMixedCheck(EtlModel m) { - for (TopLevelModelElement e : m.getElements()) { + for (TopLevelModelElement e: m.getElements()) { if (e instanceof Check) { - if (getFormulaType(((Check) e).getFormula()) == FormulaType.MIXED) { + if (getFormulaType(((Check)e).getFormula()) == FormulaType.MIXED) { return true; } } @@ -146,7 +146,7 @@ public class FormulaHelper { visit(phi, aps); boolean hasMTL = false; boolean hasSTL = false; - for (ApFormula f : aps) { + for (ApFormula f: aps) { if (f.getMtlAP() != null) { hasMTL = true; } else { @@ -165,50 +165,51 @@ public class FormulaHelper { private static void visit(Formula f, List aps) { if (f instanceof ApFormula) { - aps.add((ApFormula) f); + aps.add((ApFormula)f); } else if (f instanceof ReferenceFormula) { - visit(((ReferenceFormula) f).getDef().getFormula(), aps); + visit(((ReferenceFormula)f).getDef().getFormula(), aps); } else if (f instanceof AndOrFormula) { - visit(((AndOrFormula) f).getLeft(), aps); - visit(((AndOrFormula) f).getRight(), aps); + visit(((AndOrFormula)f).getLeft(), aps); + visit(((AndOrFormula)f).getRight(), aps); } else if (f instanceof IfThenFormula) { - visit(((IfThenFormula) f).getLeft(), aps); - visit(((IfThenFormula) f).getRight(), aps); + visit(((IfThenFormula)f).getLeft(), aps); + visit(((IfThenFormula)f).getRight(), aps); } else if (f instanceof NotFormula) { - visit(((NotFormula) f).getFormula(), aps); + visit(((NotFormula)f).getFormula(), aps); } else if (f instanceof FinallyFormula) { - visit(((FinallyFormula) f).getFormula(), aps); + visit(((FinallyFormula)f).getFormula(), aps); } else if (f instanceof FinallyUntimedFormula) { - visit(((FinallyUntimedFormula) f).getFormula(), aps); + visit(((FinallyUntimedFormula)f).getFormula(), aps); } else if (f instanceof GloballyFormula) { - visit(((GloballyFormula) f).getFormula(), aps); + visit(((GloballyFormula)f).getFormula(), aps); } else if (f instanceof GloballyUntimedFormula) { - visit(((GloballyUntimedFormula) f).getFormula(), aps); + visit(((GloballyUntimedFormula)f).getFormula(), aps); } else if (f instanceof UntilFormula) { - visit(((UntilFormula) f).getLeft(), aps); - visit(((UntilFormula) f).getRight(), aps); + visit(((UntilFormula)f).getLeft(), aps); + visit(((UntilFormula)f).getRight(), aps); } else if (f instanceof UntilUntimedFormula) { - visit(((UntilUntimedFormula) f).getLeft(), aps); - visit(((UntilUntimedFormula) f).getRight(), aps); + visit(((UntilUntimedFormula)f).getLeft(), aps); + visit(((UntilUntimedFormula)f).getRight(), aps); } } /** - * Creates a map from signal names ({@link TraceSignal} instances) to {@link IPsop}s. The Psops from the - * ITrace data are copied so that we can manipulate them (projection to time domain) + * Creates a map from signal names ({@link TraceSignal} instances) to {@link IPsop}s. The Psops from the ITrace data + * are copied so that we can manipulate them (projection to time domain) */ - public static Map createSignalMap(ITrace trace, List signalDefs, - boolean includeDerived) throws FormulaBuilderException { + public static Map createSignalMap(ITrace trace, List signalDefs, boolean includeDerived) + throws FormulaBuilderException + { Map signalMap = new HashMap(); if (signalDefs.isEmpty()) { return signalMap; } - for (SignalDef signalDef : signalDefs) { + for (SignalDef signalDef: signalDefs) { Signal s = signalDef.getSignal(); if (s instanceof TraceSignal) { - Map filter = FormulaBuilder.toMap(((TraceSignal) s).getFilter(), null); + Map filter = FormulaBuilder.toMap(((TraceSignal)s).getFilter(), null); boolean found = false; - for (IPsop psop : trace.getSignals()) { + for (IPsop psop: trace.getSignals()) { if (TraceHelper.matches(filter, psop.getAttributes())) { if (!found) { signalMap.put(signalDef.getName(), PsopHelper.copy(psop)); @@ -235,28 +236,30 @@ public class FormulaHelper { public static IPsop getDerivedSignal(ITrace trace, Signal signal) throws FormulaBuilderException { if (signal instanceof ThroughputSignal) { - return getDerivedTPsignal(trace, (ThroughputSignal) signal); + return getDerivedTPsignal(trace, (ThroughputSignal)signal); } else if (signal instanceof LatencySignal) { - return getDerivedLatSignal(trace, (LatencySignal) signal); + return getDerivedLatSignal(trace, (LatencySignal)signal); } else if (signal instanceof WipSignal) { - return getDerivedWipSignal(trace, (WipSignal) signal); + return getDerivedWipSignal(trace, (WipSignal)signal); } else if (signal instanceof ResourceAmountSignal) { - return getDerivedResourceAmountSignal(trace, (ResourceAmountSignal) signal); + return getDerivedResourceAmountSignal(trace, (ResourceAmountSignal)signal); } else if (signal instanceof ResourceClientSignal) { - return getDerivedResourceClientSignal(trace, (ResourceClientSignal) signal); + return getDerivedResourceClientSignal(trace, (ResourceClientSignal)signal); } return null; } private static IPsop getDerivedResourceClientSignal(ITrace trace, ResourceClientSignal signal) - throws FormulaBuilderException { + throws FormulaBuilderException + { SignalModifier mod = getModifier(signal.getConvSpec()); IResource resource = findResource(trace, signal.getFilter()); return SignalUtil.getResourceClients(trace, resource, mod); } private static IPsop getDerivedResourceAmountSignal(ITrace trace, ResourceAmountSignal signal) - throws FormulaBuilderException { + throws FormulaBuilderException + { SignalModifier mod = getModifier(signal.getConvSpec()); IResource resource = findResource(trace, signal.getFilter()); return SignalUtil.getResourceAmount(trace, resource, mod); @@ -284,15 +287,14 @@ public class FormulaHelper { return SignalUtil.getTP(trace, signal.getIdAtt(), scaleUnit, windowWidth, windowTimeUnit); } else { return SignalUtil.getTP(trace.getTimeUnit(), TraceHelper.getDomain(trace), - filterEvents(trace, signal.getAp()), scaleUnit, windowWidth, windowTimeUnit); + filterEvents(trace, signal.getAp()), scaleUnit, windowWidth, windowTimeUnit); } } - private static IResource findResource(ITrace trace, AttributeFilter keyvals) - throws FormulaBuilderException { + private static IResource findResource(ITrace trace, AttributeFilter keyvals) throws FormulaBuilderException { Map filter = FormulaBuilder.toMap(keyvals, null); IResource res = null; - for (IResource r : trace.getResources()) { + for (IResource r: trace.getResources()) { if (TraceHelper.matches(filter, r.getAttributes())) { if (res != null) { throw new FormulaBuilderException("Filter " + filter + " selects multiple resources"); @@ -318,15 +320,16 @@ public class FormulaHelper { private static List filterEvents(ITrace trace, MtlAp kvs) { Map filter = new HashMap(); - for (KeyVal kv : kvs.getFilter().getKeyVals()) { + for (KeyVal kv: kvs.getFilter().getKeyVals()) { filter.put(kv.getAtt().getLeft(), kv.getVal().getLeft()); } if (kvs instanceof MtlApStart) { List events = new ArrayList<>(); - for (IEvent e : trace.getEvents()) { + for (IEvent e: trace.getEvents()) { if (e instanceof IClaimEvent) { - if (((IClaimEvent) e).getType() == ClaimEventType.START - && TraceHelper.matches(filter, e.getAttributes())) { + if (((IClaimEvent)e).getType() == ClaimEventType.START + && TraceHelper.matches(filter, e.getAttributes())) + { events.add(e); } } @@ -334,10 +337,11 @@ public class FormulaHelper { return events; } else if (kvs instanceof MtlApEnd) { List events = new ArrayList<>(); - for (IEvent e : trace.getEvents()) { + for (IEvent e: trace.getEvents()) { if (e instanceof IClaimEvent) { - if (((IClaimEvent) e).getType() == ClaimEventType.END - && TraceHelper.matches(filter, e.getAttributes())) { + if (((IClaimEvent)e).getType() == ClaimEventType.END + && TraceHelper.matches(filter, e.getAttributes())) + { events.add(e); } } @@ -380,18 +384,18 @@ public class FormulaHelper { public static double getFactor(TimeUnit traceTimeUnit, TimeUnitEnum specTimeUnit) { switch (specTimeUnit) { - case NS: - return SignalUtil.convert(traceTimeUnit, 1d, TimeUnit.NANOSECONDS); - case US: - return SignalUtil.convert(traceTimeUnit, 1d, TimeUnit.MICROSECONDS); - case MS: - return SignalUtil.convert(traceTimeUnit, 1d, TimeUnit.MILLISECONDS); - case S: - return SignalUtil.convert(traceTimeUnit, 1d, TimeUnit.SECONDS); - case MIN: - return SignalUtil.convert(traceTimeUnit, 1d, TimeUnit.MINUTES); - case HR: - return SignalUtil.convert(traceTimeUnit, 1d, TimeUnit.HOURS); + case NS: + return SignalUtil.convert(traceTimeUnit, 1d, TimeUnit.NANOSECONDS); + case US: + return SignalUtil.convert(traceTimeUnit, 1d, TimeUnit.MICROSECONDS); + case MS: + return SignalUtil.convert(traceTimeUnit, 1d, TimeUnit.MILLISECONDS); + case S: + return SignalUtil.convert(traceTimeUnit, 1d, TimeUnit.SECONDS); + case MIN: + return SignalUtil.convert(traceTimeUnit, 1d, TimeUnit.MINUTES); + case HR: + return SignalUtil.convert(traceTimeUnit, 1d, TimeUnit.HOURS); } throw new UnsupportedOperationException(); } diff --git a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/GenerateEtl.mwe2 b/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/GenerateEtl.mwe2 index feedd62486edb6a920061f5bf6f9fb05249c2072..18f67e1ac91782b8f6b3e26a836029dde16b1c5d 100644 --- a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/GenerateEtl.mwe2 +++ b/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/GenerateEtl.mwe2 @@ -42,21 +42,23 @@ Workflow { serializer = { generateStub = false } + formatter = { + generateXtendStub = true + } + generator = { + generateStub = false + } + scopeProvider = { + generateStub = false + } validator = { // Generates checks for @Deprecated grammar annotations, // an IssueProvider and a corresponding PropertyPage generateDeprecationValidation = true } - generator = { - generateXtendStub = true - } junitSupport = { junitVersion = "5" } - formatter = { - generateStub = true - generateXtendStub = true - } } } } diff --git a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/VerificationHelper.java b/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/VerificationHelper.java index 06bd9cc5db88d7b19a0219679620add03bb06f28..b36ffb6de15a3cac3c5c9799f3b2e57cf5f8a37f 100644 --- a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/VerificationHelper.java +++ b/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/VerificationHelper.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.tl; import java.util.ArrayList; @@ -34,7 +35,6 @@ import org.eclipse.trace4cps.tl.etl.SignalDef; import org.eclipse.trace4cps.tl.etl.TraceSignal; public class VerificationHelper { - private final ITrace trace; private final EtlModel model; @@ -94,7 +94,7 @@ public class VerificationHelper { counterExamples.add(InformativePrefix.BAD); counterExamples.add(InformativePrefix.NON_INFORMATIVE); MtlFuture f = engine.checkAll(states, verificationResult.getChecks(), counterExamples, true); - for (MtlResult checkResult : f.get()) { + for (MtlResult checkResult: f.get()) { verificationResult.setResult(checkResult); } return verificationResult; @@ -104,7 +104,7 @@ public class VerificationHelper { * Adds the non-{@link TraceSignal} signals to the signalmap and projects them to dom */ private void addDerivedSignals() throws FormulaBuilderException { - for (SignalDef signalDef : FormulaBuilder.get(model, SignalDef.class)) { + for (SignalDef signalDef: FormulaBuilder.get(model, SignalDef.class)) { Signal signal = signalDef.getSignal(); if (!(signal instanceof TraceSignal)) { IPsop psop = FormulaHelper.getDerivedSignal(trace, signal); @@ -112,8 +112,7 @@ public class VerificationHelper { PsopHelper.projectTo(psop, dom); signalMap.put(signalDef.getName(), psop); } else { - throw new FormulaBuilderException( - "Psop for " + signalDef.getName() + " is empty on domain " + dom); + throw new FormulaBuilderException("Psop for " + signalDef.getName() + " is empty on domain " + dom); } } } @@ -121,7 +120,7 @@ public class VerificationHelper { private List projectDiscreteStates() { List states = new ArrayList(); - for (State state : trace.getEvents()) { + for (State state: trace.getEvents()) { if (dom.contains(state.getTimestamp())) { states.add(state); } @@ -134,7 +133,8 @@ public class VerificationHelper { double domWidth = dom.ub().doubleValue() - dom.lb().doubleValue(); double stepSize = domWidth / 10000; // ~10.000 dummy states - for (int i = 0; i < states.size() - 1; i++) { + int i = 0; + while (i < states.size() - 1) { State si = states.get(i); State sj = states.get(i + 1); double delta = sj.getTimestamp().doubleValue() - si.getTimestamp().doubleValue(); @@ -149,6 +149,7 @@ public class VerificationHelper { } i += k; } + i++; } return cnt; } @@ -156,7 +157,7 @@ public class VerificationHelper { private IInterval computeCommonTimeDomain(Collection psops) { Interval dom = new Interval(trace.getEvents().get(0).getTimestamp(), false, trace.getEvents().get(trace.getEvents().size() - 1).getTimestamp(), false); - for (IPsop p : psops) { + for (IPsop p: psops) { dom = Interval.intersect(dom, PsopHelper.dom(p)); } return dom; diff --git a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/VerificationResult.java b/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/VerificationResult.java index 4488094b3c90df5785b0ddd26714dca147a9e115..7095e83e2122cff148c597076147d47527b3350d 100644 --- a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/VerificationResult.java +++ b/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/VerificationResult.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.tl; import java.util.Collection; @@ -77,7 +78,7 @@ public final class VerificationResult { } public MtlResult getResult(String name) { - for (Map.Entry e : formula2name.entrySet()) { + for (Map.Entry e: formula2name.entrySet()) { if (name.equals(e.getValue())) { MtlFormula phi = e.getKey(); if (isQuantifiedCheck(phi)) { @@ -90,7 +91,7 @@ public final class VerificationResult { } public MtlResult getResult(String name, int i) { - for (Map.Entry e : formula2name.entrySet()) { + for (Map.Entry e: formula2name.entrySet()) { if (name.equals(e.getValue())) { MtlFormula phi = e.getKey(); if (!isQuantifiedCheck(phi)) { diff --git a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/formatting2/EtlFormatter.xtend b/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/formatting2/EtlFormatter.xtend index 8d7734391b2d8f13be1c11c95a0c4c119d1d5137..3c07162376cf67cd642b3fea603a4235d6278196 100644 --- a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/formatting2/EtlFormatter.xtend +++ b/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/formatting2/EtlFormatter.xtend @@ -1,36 +1,32 @@ /** * Copyright (c) 2021 Contributors to the Eclipse Foundation - * + * * This program and the accompanying materials are made * available under the terms of the Eclipse Public License 2.0 * which is available at https://www.eclipse.org/legal/epl-2.0/ - * + * * SPDX-License-Identifier: EPL-2.0 */ package org.eclipse.trace4cps.tl.formatting2 -import com.google.inject.Inject import org.eclipse.trace4cps.tl.etl.EtlModel -import org.eclipse.trace4cps.tl.services.EtlGrammarAccess import org.eclipse.xtext.formatting2.AbstractFormatter2 import org.eclipse.xtext.formatting2.IFormattableDocument class EtlFormatter extends AbstractFormatter2 { - - @Inject extension EtlGrammarAccess - def dispatch void format(EtlModel etlModel, extension IFormattableDocument document) { - // TODO: format HiddenRegions around keywords, attributes, cross references, etc. - for (_signal : etlModel.elements) { + def dispatch void format(EtlModel etlModel, extension IFormattableDocument document) { + // TODO: format HiddenRegions around keywords, attributes, cross references, etc. + for (_signal : etlModel.elements) { _signal.format _signal.append[newLines = 2] - } - } -// -// def dispatch void format(Def _def, extension IFormattableDocument document) { -// // TODO: format HiddenRegions around keywords, attributes, cross references, etc. -// _def.formula.format -// } - - // TODO: implement for Check, Formula, Globally0, Finally0, Globally1, Finally1, IfThenFormula, AndFormula, OrFormula, Until0, Until1, NotFormula, MTLleaf, KeyVal, Interval + } + } + + // TODO: implement for Def, Check, Formula, Globally0, Finally0, Globally1, Finally1, IfThenFormula, AndFormula, + // OrFormula, Until0, Until1, NotFormula, MTLleaf, KeyVal, Interval +// def dispatch void format(Def _def, extension IFormattableDocument document) { +// // TODO: format HiddenRegions around keywords, attributes, cross references, etc. +// _def.formula.format +// } } diff --git a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/generator/EtlGenerator.xtend b/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/generator/EtlGenerator.xtend deleted file mode 100644 index c31e315d4f53f3fe35b8d7e06e0bbe2b42f86d01..0000000000000000000000000000000000000000 --- a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/generator/EtlGenerator.xtend +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) 2021 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.trace4cps.tl.generator - -import org.eclipse.emf.ecore.resource.Resource -import org.eclipse.xtext.generator.AbstractGenerator -import org.eclipse.xtext.generator.IFileSystemAccess2 -import org.eclipse.xtext.generator.IGeneratorContext - -/** - * Generates code from your model files on save. - * - * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#code-generation - */ -class EtlGenerator extends AbstractGenerator { - - override void doGenerate(Resource resource, IFileSystemAccess2 fsa, IGeneratorContext context) { - } -} diff --git a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/scoping/EtlScopeProvider.java b/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/scoping/EtlScopeProvider.java deleted file mode 100644 index 30d6ee2a57bd15fcdc537bc3ea5e6201d3afdaf2..0000000000000000000000000000000000000000 --- a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/scoping/EtlScopeProvider.java +++ /dev/null @@ -1,20 +0,0 @@ -/* - * Copyright (c) 2021 Contributors to the Eclipse Foundation - * - * This program and the accompanying materials are made - * available under the terms of the Eclipse Public License 2.0 - * which is available at https://www.eclipse.org/legal/epl-2.0/ - * - * SPDX-License-Identifier: EPL-2.0 - */ -package org.eclipse.trace4cps.tl.scoping; - -/** - * This class contains custom scoping description. - * - * See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#scoping on how and when to use - * it. - */ -public class EtlScopeProvider extends AbstractEtlScopeProvider { - -} diff --git a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/validation/CycleDetector.java b/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/validation/CycleDetector.java index cdf16460b245b4890f099b9660797822f430ff3f..fe6ad861b32468e60504501b0bf51fa7079e273d 100644 --- a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/validation/CycleDetector.java +++ b/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/validation/CycleDetector.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.tl.validation; import java.util.HashMap; @@ -15,7 +16,6 @@ import java.util.Map; import java.util.Set; public class CycleDetector { - private final Set vertices = new HashSet<>(); private final Map> successors = new HashMap<>(); @@ -36,7 +36,7 @@ public class CycleDetector { private boolean dfs(String v, Set white, Set grey, Set black) { white.remove(v); grey.add(v); - for (String w : successors.get(v)) { + for (String w: successors.get(v)) { if (black.contains(w)) { continue; } @@ -59,7 +59,7 @@ public class CycleDetector { white.addAll(vertices); while (!white.isEmpty()) { - for (String v : vertices) { + for (String v: vertices) { if (white.contains(v)) { if (dfs(v, white, grey, black)) { return true; diff --git a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/validation/EtlValidator.java b/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/validation/EtlValidator.java index 94aafe952db98c3c23c94ec4fd559235e913c6cb..56f05868106cfb1f5e4c9820dac3b4421583d8ec 100644 --- a/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/validation/EtlValidator.java +++ b/temporallogic/org.eclipse.trace4cps.tl/src/org/eclipse/trace4cps/tl/validation/EtlValidator.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.tl.validation; import java.util.Collections; @@ -35,11 +36,11 @@ import org.eclipse.xtext.validation.CheckType; /** * This class contains custom validation rules. - * + *

* See https://www.eclipse.org/Xtext/documentation/303_runtime_concepts.html#validation + *

*/ public class EtlValidator extends AbstractEtlValidator { - @Check(CheckType.FAST) public void infoSTLmixFormulas(org.eclipse.trace4cps.tl.etl.Check c) { if (FormulaHelper.getFormulaType(c.getFormula()) == FormulaType.MIXED) { @@ -52,7 +53,8 @@ public class EtlValidator extends AbstractEtlValidator { boolean leftIsSTL = FormulaHelper.getFormulaType(f.getLeft()) == FormulaType.STL; boolean rightIsSTL = FormulaHelper.getFormulaType(f.getRight()) == FormulaType.STL; if (leftIsSTL && rightIsSTL) { - info("General until not supported for STL: reverting to sampling semantics", EtlPackage.Literals.UNTIL_FORMULA__LEFT); + info("General until not supported for STL: reverting to sampling semantics", + EtlPackage.Literals.UNTIL_FORMULA__LEFT); } } @@ -61,14 +63,15 @@ public class EtlValidator extends AbstractEtlValidator { boolean leftIsSTL = FormulaHelper.getFormulaType(f.getLeft()) == FormulaType.STL; boolean rightIsSTL = FormulaHelper.getFormulaType(f.getRight()) == FormulaType.STL; if (leftIsSTL && rightIsSTL) { - info("General until not supported for STL: reverting to sampling semantics", EtlPackage.Literals.UNTIL_UNTIMED_FORMULA__LEFT); + info("General until not supported for STL: reverting to sampling semantics", + EtlPackage.Literals.UNTIL_UNTIMED_FORMULA__LEFT); } } @Check(CheckType.FAST) public void checkUniqueTopLevelIDs(TopLevelModelElement e) { - EtlModel m = (EtlModel) e.eContainer(); - for (TopLevelModelElement e2 : m.getElements()) { + EtlModel m = (EtlModel)e.eContainer(); + for (TopLevelModelElement e2: m.getElements()) { if (!e.equals(e2) && e.getName().equals(e2.getName())) { error("Duplicate identifier", EtlPackage.Literals.TOP_LEVEL_MODEL_ELEMENT__NAME); } @@ -114,7 +117,7 @@ public class EtlValidator extends AbstractEtlValidator { for (TreeIterator it = model.eAllContents(); it.hasNext();) { EObject o = it.next(); if (o instanceof ReferenceFormula) { - ReferenceFormula ref = (ReferenceFormula) o; + ReferenceFormula ref = (ReferenceFormula)o; Def src = FormulaHelper.findContainer(ref, Def.class); if (src != null) { det.addEdge(src.getName(), ref.getDef().getName()); @@ -124,10 +127,9 @@ public class EtlValidator extends AbstractEtlValidator { } } if (det.hasCycle()) { - for (Map.Entry e : map.entrySet()) { + for (Map.Entry e: map.entrySet()) { // if (det.hasCycle(e.getKey())) { - error("Cycle in definitions", e.getValue(), - EtlPackage.Literals.TOP_LEVEL_MODEL_ELEMENT__NAME); + error("Cycle in definitions", e.getValue(), EtlPackage.Literals.TOP_LEVEL_MODEL_ELEMENT__NAME); // } } } @@ -178,7 +180,8 @@ public class EtlValidator extends AbstractEtlValidator { if (def != null) { return def.getParam() != null && param.equals(def.getParam()); } - org.eclipse.trace4cps.tl.etl.Check check = FormulaHelper.findContainer(obj, org.eclipse.trace4cps.tl.etl.Check.class); + org.eclipse.trace4cps.tl.etl.Check check = FormulaHelper.findContainer(obj, + org.eclipse.trace4cps.tl.etl.Check.class); if (check != null) { return check.getVar() != null && param.equals(check.getVar()); } @@ -186,16 +189,15 @@ public class EtlValidator extends AbstractEtlValidator { } private boolean paramUsed(String param, EObject root) { - for (TreeIterator it = EcoreUtil.getAllContents(Collections.singletonList(root)); it - .hasNext();) { + for (TreeIterator it = EcoreUtil.getAllContents(Collections.singletonList(root)); it.hasNext();) { Object next = it.next(); if (next instanceof IdString) { - IdString id = (IdString) next; + IdString id = (IdString)next; if (param.equals(id.getId())) { return true; } } else if (next instanceof ReferenceFormula) { - ReferenceFormula r = (ReferenceFormula) next; + ReferenceFormula r = (ReferenceFormula)next; if (param.equals(r.getParam())) { return true; } diff --git a/trace/org.eclipse.trace4cps.core.tests/.checkstyle b/trace/org.eclipse.trace4cps.core.tests/.checkstyle new file mode 100644 index 0000000000000000000000000000000000000000..b01fc54c7363d48a5fce265944ff35f3519d22f6 --- /dev/null +++ b/trace/org.eclipse.trace4cps.core.tests/.checkstyle @@ -0,0 +1,7 @@ + + + + + + + diff --git a/trace/org.eclipse.trace4cps.core.tests/.project b/trace/org.eclipse.trace4cps.core.tests/.project index 944a764c3b6fa7a722780ebbcb17c50ff1a9becf..db44099291a5ca9415dfb047db8ea4f2a1f99dfc 100644 --- a/trace/org.eclipse.trace4cps.core.tests/.project +++ b/trace/org.eclipse.trace4cps.core.tests/.project @@ -20,9 +20,15 @@ + + net.sf.eclipsecs.core.CheckstyleBuilder + + + org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + net.sf.eclipsecs.core.CheckstyleNature diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/behavior/test/BehavioralAnalysisTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/behavior/test/BehavioralAnalysisTest.java index dc62d23f34209f8a0f001e155e965aefd2fa467b..bd288211427cba40b9678285cb73952201cb8168 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/behavior/test/BehavioralAnalysisTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/behavior/test/BehavioralAnalysisTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.behavior.test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -29,12 +30,10 @@ import org.eclipse.trace4cps.core.impl.Trace; import org.junit.jupiter.api.Test; public class BehavioralAnalysisTest { - @Test public void testPartition1() { // Identity of claims is decided by id, type: the three behaviors are not equal. - BehavioralPartition p = - BehavioralAnalysis.partition(getTrace1(), "id", Collections.singleton("type")); + BehavioralPartition p = BehavioralAnalysis.partition(getTrace1(), "id", Collections.singleton("type")); assertEquals(3, p.size()); } @@ -42,16 +41,14 @@ public class BehavioralAnalysisTest { public void testPartition2() { // Identity of claims is decided by id and name only: two behaviors are // equal, and the third is different because A and B overlap - BehavioralPartition p = - BehavioralAnalysis.partition(getTrace1(), "id", Collections.singleton("name")); + BehavioralPartition p = BehavioralAnalysis.partition(getTrace1(), "id", Collections.singleton("name")); assertEquals(2, p.size()); } @Test public void testHistogram1() { // Identity of claims is decided by id, type and resource: the three behaviors are not equal. - BehavioralPartition p = - BehavioralAnalysis.partition(getTrace1(), "id", Collections.singleton("type")); + BehavioralPartition p = BehavioralAnalysis.partition(getTrace1(), "id", Collections.singleton("type")); List h = BehavioralAnalysis.createBehavioralHistogram(p); assertEquals(3, h.size()); HistogramEntry e0 = h.get(0); @@ -100,8 +97,7 @@ public class BehavioralAnalysisTest { return trace.getEvents(); } - private IClaim createODSEclaim(Trace trace, String name, int id, String type, double t0, double t1, - IResource r) { + private IClaim createODSEclaim(Trace trace, String name, int id, String type, double t0, double t1, IResource r) { Map m1 = new HashMap(); m1.put("name", name); m1.put("id", Integer.toString(id)); @@ -110,5 +106,4 @@ public class BehavioralAnalysisTest { c.setAttributes(m1); return c; } - } diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/behavior/test/FilteringClaimRepresentationTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/behavior/test/FilteringClaimRepresentationTest.java index 562ce8287d34e0d236a52a50bcf1d3de7880bbcf..cb1233edb71830d3450fb83acc6e469ed02ec4fb 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/behavior/test/FilteringClaimRepresentationTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/behavior/test/FilteringClaimRepresentationTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.behavior.test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -24,44 +25,42 @@ import org.eclipse.trace4cps.core.impl.Resource; import org.junit.jupiter.api.Test; public class FilteringClaimRepresentationTest { + private static final IResource R = new Resource(100, false); - private static final IResource r = new Resource(100, false); - { - r.setAttribute("name", "CPU"); - } + private static final Map M1 = new HashMap(); - private static final Map m1 = new HashMap(); - { - m1.put(1, 23); - m1.put(2, 25); - m1.put(3, 38); - } + private static final Set U0 = new HashSet(); + + private static final Set U1 = new HashSet(); + + static { + R.setAttribute("name", "CPU"); - private static final Set u0 = new HashSet(); + M1.put(1, 23); + M1.put(2, 25); + M1.put(3, 38); - private static final Set u1 = new HashSet(); - { - u1.add("type"); + U1.add("type"); } @Test public void testRemap() { - FilteringClaimRepresentation f = new FilteringClaimRepresentation("id", u0, m1); - IClaim claim = new Claim(0, 10, r, 10, attMap("id", "1")); + FilteringClaimRepresentation f = new FilteringClaimRepresentation("id", U0, M1); + IClaim claim = new Claim(0, 10, R, 10, attMap("id", "1")); assertEquals("id=23;res={name=CPU};s", f.represent(claim.getStartEvent())); } @Test public void testUniqueness1() { - FilteringClaimRepresentation f = new FilteringClaimRepresentation("id", u0, m1); - IClaim claim = new Claim(0, 10, r, 10, attMap("id", "3", "type", "LOW")); + FilteringClaimRepresentation f = new FilteringClaimRepresentation("id", U0, M1); + IClaim claim = new Claim(0, 10, R, 10, attMap("id", "3", "type", "LOW")); assertEquals("id=38;res={name=CPU};e", f.represent(claim.getEndEvent())); } @Test public void testUniqueness2() { - FilteringClaimRepresentation f = new FilteringClaimRepresentation("id", u1, m1); - IClaim claim = new Claim(0, 10, r, 10, attMap("id", "3", "type", "LOW")); + FilteringClaimRepresentation f = new FilteringClaimRepresentation("id", U1, M1); + IClaim claim = new Claim(0, 10, R, 10, attMap("id", "3", "type", "LOW")); assertEquals("id=38;type=LOW;res={name=CPU};s", f.represent(claim.getStartEvent())); } diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/constraintgraph/test/ConstraintGraphTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/constraintgraph/test/ConstraintGraphTest.java index d81fb240af814a48576888c8d78d495ea0f4d40e..0f340d100d24d3dff8ec173a6d3957147d2b3838 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/constraintgraph/test/ConstraintGraphTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/constraintgraph/test/ConstraintGraphTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.constraintgraph.test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -20,8 +21,6 @@ import org.eclipse.trace4cps.analysis.constraintgraph.impl.ClaimNode; import org.eclipse.trace4cps.analysis.constraintgraph.impl.Constraint; import org.eclipse.trace4cps.analysis.constraintgraph.impl.ConstraintGraph; import org.eclipse.trace4cps.analysis.constraintgraph.impl.ConstraintGraphNode; -import org.eclipse.trace4cps.analysis.constraintgraph.impl.EventNode; -import org.eclipse.trace4cps.analysis.cpa.CriticalPathAnalysis; import org.eclipse.trace4cps.analysis.cpa.PositiveCycleException; import org.eclipse.trace4cps.analysis.cpa.test.CPATest; import org.eclipse.trace4cps.analysis.mtl.DefaultAtomicProposition; @@ -36,7 +35,6 @@ import org.eclipse.trace4cps.core.impl.Trace; import org.junit.jupiter.api.Test; public class ConstraintGraphTest { - @Test public void testSimple() { ConstraintGraph cg = new ConstraintGraph(createDummyModel()); @@ -183,12 +181,12 @@ public class ConstraintGraphTest { assertEquals(10, cg.size()); DefaultAtomicProposition matchStart = new DefaultAtomicProposition(ClaimEventType.START); DefaultAtomicProposition matchEnd = new DefaultAtomicProposition(ClaimEventType.END); - for (ConstraintGraphNode e : cg.getNodes()) { + for (ConstraintGraphNode e: cg.getNodes()) { if (e instanceof ClaimNode) { - if (((ClaimNode) e).isClaimStart()) { - assertTrue(((ClaimNode) e).getEvent().satisfies(matchStart)); + if (((ClaimNode)e).isClaimStart()) { + assertTrue(((ClaimNode)e).getEvent().satisfies(matchStart)); } else { - assertTrue(((ClaimNode) e).getEvent().satisfies(matchEnd)); + assertTrue(((ClaimNode)e).getEvent().satisfies(matchEnd)); } } } @@ -201,7 +199,7 @@ public class ConstraintGraphTest { cfg.setAddSourceAndSink(true); cfg.setUseDependencies(true); ConstraintGraph cg = new ConstraintGraph(trace, cfg); - + assertEquals(10, cg.size()); assertEquals(27, cg.edgeSize()); @@ -209,7 +207,7 @@ public class ConstraintGraphTest { assertClaimDurationConstraint(cg, "B", 0); assertClaimDurationConstraint(cg, "C", 0); assertClaimDurationConstraint(cg, "D", 5); - + assertESConstraint(cg, "A", "B", 0); assertESConstraint(cg, "B", "C", 0); assertESConstraint(cg, "C", "D", 0); @@ -239,7 +237,7 @@ public class ConstraintGraphTest { private void assertConstraint(ConstraintGraphNode src, double weigth, ConstraintGraphNode dst) { boolean found = false; - for (Constraint c : src.constraints()) { + for (Constraint c: src.constraints()) { if (c.getDst() == dst && c.weight() == weigth) { found = true; break; @@ -249,10 +247,10 @@ public class ConstraintGraphTest { } private ConstraintGraphNode find(ConstraintGraph cg, String name, boolean isStart) { - for (ConstraintGraphNode ce : cg.getNodes()) { + for (ConstraintGraphNode ce: cg.getNodes()) { if (ce instanceof ClaimNode) { - IClaim c = ((ClaimNode) ce).getClaim(); - if (((ClaimNode) ce).isClaimStart() == isStart && name.equals(c.getAttributeValue("name"))) { + IClaim c = ((ClaimNode)ce).getClaim(); + if (((ClaimNode)ce).isClaimStart() == isStart && name.equals(c.getAttributeValue("name"))) { return ce; } } diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/cpa/test/CPATest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/cpa/test/CPATest.java index ac988f549a8aa6eb5662a9710c80e3323f6449e7..6bce2856bdcc952905b00d5580e12fb3e1f3781f 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/cpa/test/CPATest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/cpa/test/CPATest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.cpa.test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -31,7 +32,6 @@ import org.eclipse.trace4cps.core.impl.Trace; import org.junit.jupiter.api.Test; public final class CPATest { - @Test public void testCPAsimple() throws PositiveCycleException { ITrace trace = createDummyModel(); @@ -51,7 +51,6 @@ public final class CPATest { checkCritical(result, "A", "B", "D", "E"); DependencyProvider p = new DependencyProvider() { - @Override public boolean isApplicationDependency(IEvent src, IEvent dst) { if (src.getAttributeValue("name").equals("A") && dst.getAttributeValue("name").equals("C")) { @@ -79,7 +78,6 @@ public final class CPATest { checkCritical(result, "A", "B", "C", "D"); DependencyProvider p = new DependencyProvider() { - @Override public boolean isApplicationDependency(IEvent src, IEvent dst) { if (src.getAttributeValue("name").equals("B") && dst.getAttributeValue("name").equals("D")) { @@ -178,11 +176,11 @@ public final class CPATest { private void checkCritical(CpaResult r, String... names) { Set critical = new HashSet(); Set given = new HashSet(); - for (IDependency dep : r.getCriticalDeps()) { + for (IDependency dep: r.getCriticalDeps()) { critical.add(dep.getSrc().getAttributeValue("name")); critical.add(dep.getDst().getAttributeValue("name")); } - for (String n : names) { + for (String n: names) { given.add(n); } assertEquals(given, critical); @@ -191,12 +189,12 @@ public final class CPATest { private void checkBlocked(CpaResult r, DependencyProvider p, String... names) { Set blocked = new HashSet(); Set given = new HashSet(); - for (IDependency d : r.getCriticalDeps()) { + for (IDependency d: r.getCriticalDeps()) { if (CpaResult.isNonAppDependency(d, p)) { blocked.add(d.getDst().getAttributeValue("name")); } } - for (String n : names) { + for (String n: names) { given.add(n); } assertEquals(given, blocked); @@ -293,5 +291,4 @@ public final class CPATest { } return r; } - } diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/dist/test/DependencyAnalysisTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/dist/test/DependencyAnalysisTest.java index 3d6033d1d34d3dbb403a4e040fe8f4bdd20d0fe9..3fd7b118ec4e13c3eebdb7a4fb076d168e4ebf62 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/dist/test/DependencyAnalysisTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/dist/test/DependencyAnalysisTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.dist.test; import java.util.List; @@ -22,7 +23,6 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; public class DependencyAnalysisTest { - private static final String W = "weight"; @Test diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/dist/test/DistanceAnalysisTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/dist/test/DistanceAnalysisTest.java index 96078929d27975c7b6f245a9cb7c2754b021bc4f..7d72e2f61e249fa073bd96562821e3f9e55913e7 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/dist/test/DistanceAnalysisTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/dist/test/DistanceAnalysisTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.dist.test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -19,13 +20,11 @@ import org.eclipse.trace4cps.core.ITrace; import org.junit.jupiter.api.Test; public final class DistanceAnalysisTest { - @Test public void testSimple() { ITrace reference = CPATest.createDummyModel(); ITrace traceToAnnotate = CPATest.createDummyModel4(); - DistanceResult diff = - DistanceAnalysis.distance(reference, traceToAnnotate, new DefaultRepresentation(), false); + DistanceResult diff = DistanceAnalysis.distance(reference, traceToAnnotate, new DefaultRepresentation(), false); assertEquals(15, diff.getDistance()); assertEquals(3, diff.getInterestCount().size()); } diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/mtl/check/test/CompactExplanationTableImplTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/mtl/check/test/CompactExplanationTableImplTest.java index c0e5cff006f9d3b184979b42015d2d0a94345d53..85385a865aadf80219e0cdba50c4aa63cac6e53e 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/mtl/check/test/CompactExplanationTableImplTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/mtl/check/test/CompactExplanationTableImplTest.java @@ -7,9 +7,14 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl.check.test; -import static org.eclipse.trace4cps.analysis.mtl.MtlBuilder.*; +import static org.eclipse.trace4cps.analysis.mtl.MtlBuilder.F; +import static org.eclipse.trace4cps.analysis.mtl.MtlBuilder.G; +import static org.eclipse.trace4cps.analysis.mtl.MtlBuilder.IMPLY; +import static org.eclipse.trace4cps.analysis.mtl.MtlBuilder.OR; +import static org.eclipse.trace4cps.analysis.mtl.MtlBuilder.TRUE; import static org.eclipse.trace4cps.analysis.mtl.check.TabularExplanationTable.MAYBE; import static org.eclipse.trace4cps.analysis.mtl.check.TabularExplanationTable.UNKNOWN; import static org.eclipse.trace4cps.analysis.mtl.check.TabularExplanationTable.YES; @@ -23,22 +28,20 @@ import java.util.Map; import org.eclipse.trace4cps.analysis.mtl.AtomicProposition; import org.eclipse.trace4cps.analysis.mtl.DefaultAtomicProposition; +import org.eclipse.trace4cps.analysis.mtl.ExplanationTable.Region; import org.eclipse.trace4cps.analysis.mtl.MtlBuilder; import org.eclipse.trace4cps.analysis.mtl.MtlException; import org.eclipse.trace4cps.analysis.mtl.MtlFormula; import org.eclipse.trace4cps.analysis.mtl.MtlUtil; import org.eclipse.trace4cps.analysis.mtl.State; -import org.eclipse.trace4cps.analysis.mtl.ExplanationTable.Region; import org.eclipse.trace4cps.analysis.mtl.check.CompactExplanationTableImpl; import org.eclipse.trace4cps.analysis.mtl.check.TabularExplanationTable; import org.eclipse.trace4cps.core.impl.Interval; import org.junit.jupiter.api.Test; public class CompactExplanationTableImplTest { - @Test public void testSetGet() throws MtlException { - List trace = new ArrayList(); trace.add(new DefaultState(1, "a")); trace.add(new DefaultState(2, "b")); @@ -47,8 +50,7 @@ public class CompactExplanationTableImplTest { AtomicProposition a = new DefaultAtomicProposition("a", "a"); AtomicProposition b = new DefaultAtomicProposition("b", "b"); - MtlFormula phi = - G(IMPLY(a, OR(F(b, new Interval(0, false, 3, false)), F(G(MtlBuilder.TRUE()))))); + MtlFormula phi = G(IMPLY(a, OR(F(b, new Interval(0, false, 3, false)), F(G(MtlBuilder.TRUE()))))); Map idMap = getIdMap(phi); assertEquals(12, idMap.size() - 1); @@ -85,8 +87,7 @@ public class CompactExplanationTableImplTest { } AtomicProposition a = new DefaultAtomicProposition("a", "a"); AtomicProposition b = new DefaultAtomicProposition("b", "b"); - MtlFormula phi = - G(IMPLY(a, OR(F(b, new Interval(0, false, 3, false)), F(G(TRUE()))))); + MtlFormula phi = G(IMPLY(a, OR(F(b, new Interval(0, false, 3, false)), F(G(TRUE()))))); final int formulaIndex = 0; Map idMap = Collections.singletonMap(phi, formulaIndex); @@ -125,7 +126,7 @@ public class CompactExplanationTableImplTest { List sub = MtlUtil.getSubformulas(phi); idMap.clear(); int i = 0; - for (MtlFormula f : sub) { + for (MtlFormula f: sub) { idMap.put(f, i); i++; } diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/mtl/check/test/DefaultState.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/mtl/check/test/DefaultState.java index 8ac243110359293ca810fe7d43194c3fa8b430ef..dc9e21db0a509e69e274065057fd3dd7b95091d8 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/mtl/check/test/DefaultState.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/mtl/check/test/DefaultState.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl.check.test; import java.util.Map; @@ -18,11 +19,10 @@ import org.eclipse.trace4cps.core.impl.AttributeAware; import org.eclipse.trace4cps.core.impl.TraceHelper; /** - * A base implementation of the {@link State} interface. Properties are specified by a key-value mapping of - * strings. This class is intended to work with {@link DefaultAtomicProposition} instances. + * A base implementation of the {@link State} interface. Properties are specified by a key-value mapping of strings. + * This class is intended to work with {@link DefaultAtomicProposition} instances. */ public class DefaultState extends AttributeAware implements State { - private final double ts; public DefaultState(double ts) { @@ -41,7 +41,7 @@ public class DefaultState extends AttributeAware implements State { public DefaultState(double ts, Map props) { this.ts = ts; - for (Map.Entry e : props.entrySet()) { + for (Map.Entry e: props.entrySet()) { setAttribute(e.getKey(), e.getValue()); } } diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/mtl/test/MtlCheckerTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/mtl/test/MtlCheckerTest.java index 8ac91cb9ee59119150240b5de4e4cebfbc11f779..71d985b687d494d57149052b368a5a1b8045ec3a 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/mtl/test/MtlCheckerTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/mtl/test/MtlCheckerTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl.test; import static org.eclipse.trace4cps.analysis.mtl.MtlBuilder.F; @@ -48,7 +49,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; public class MtlCheckerTest { - private MtlChecker c; @BeforeEach @@ -65,7 +65,7 @@ public class MtlCheckerTest { trace.add(new DefaultState(3, "b", "b")); trace.add(new DefaultState(4, "a", "a")); MtlFormula phi = G(IMPLY(new DefaultAtomicProposition("a", "a"), - F(new DefaultAtomicProposition("b", "b"), new Interval(0, false, 3, false)))); + F(new DefaultAtomicProposition("b", "b"), new Interval(0, false, 3, false)))); assertEquals(InformativePrefix.BAD, c.check(trace, phi, null, false).informative()); } @@ -78,7 +78,7 @@ public class MtlCheckerTest { trace.add(new DefaultState(3, "b", "b")); trace.add(new DefaultState(4, "a", "a")); MtlFormula phi = G(IMPLY(new DefaultAtomicProposition("a", "a"), - F(new DefaultAtomicProposition("b", "b"), new Interval(0, false, 1, false)))); + F(new DefaultAtomicProposition("b", "b"), new Interval(0, false, 1, false)))); assertEquals(InformativePrefix.BAD, c.check(trace, phi, null, false).informative()); } @@ -106,7 +106,7 @@ public class MtlCheckerTest { AtomicProposition p = new DefaultAtomicProposition("g", "g"); MtlFormula phi1 = G(IMPLY(p, F(p, new Interval(0, true, 2, false)))); MtlFormula phi2 = G(IMPLY(p, OR(F(p, new Interval(0, true, 2, false)), - G(NOT(p), new Interval(0, true, Double.POSITIVE_INFINITY, true))))); + G(NOT(p), new Interval(0, true, Double.POSITIVE_INFINITY, true))))); assertEquals(InformativePrefix.BAD, c.check(trace, phi1, null, false).informative()); assertEquals(InformativePrefix.GOOD, c.check(trace, phi2, null, false).informative()); } @@ -119,7 +119,7 @@ public class MtlCheckerTest { trace.add(new DefaultState(7, "a", "a")); AtomicProposition p = new DefaultAtomicProposition("a", "a"); MtlFormula phi = F(G(NOT(p), new Interval(0, true, Double.POSITIVE_INFINITY, true)), - new Interval(0, false, 5, false)); + new Interval(0, false, 5, false)); MtlResult r = c.check(trace, phi, Collections.singleton(InformativePrefix.BAD), false); assertEquals(InformativePrefix.BAD, r.informative()); } @@ -262,23 +262,24 @@ public class MtlCheckerTest { } @Test - public void testLatencyVerification() throws IOException, MtlException, InterruptedException, - ExecutionException, ParseException { + public void testLatencyVerification() + throws IOException, MtlException, InterruptedException, ExecutionException, ParseException + { ITrace trace = TraceReader.readTrace(new File("../../trace-examples/odse/reference.etf")); List phis = new ArrayList<>(); for (int i = 0; i < 200; i++) { - AtomicProposition ap1 = - new DefaultAtomicProposition(ClaimEventType.START, "name", "A", "id", Integer.toString(i)); - AtomicProposition ap2 = - new DefaultAtomicProposition(ClaimEventType.END, "name", "G", "id", Integer.toString(i)); + AtomicProposition ap1 = new DefaultAtomicProposition(ClaimEventType.START, "name", "A", "id", + Integer.toString(i)); + AtomicProposition ap2 = new DefaultAtomicProposition(ClaimEventType.END, "name", "G", "id", + Integer.toString(i)); MtlFormula phi = G(IMPLY(ap1, F(ap2, new Interval(0, false, 100, false)))); phis.add(phi); } MtlFuture f = new MtlChecker().checkAll(trace.getEvents(), phis, Collections.emptySet(), false); List results = f.get(); assertEquals(200, results.size()); - for (MtlResult r : results) { + for (MtlResult r: results) { assertEquals(InformativePrefix.GOOD, r.informative()); } } diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/signal/test/EventSignalUtilTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/signal/test/EventSignalUtilTest.java index 48edc0cc8d4eb2443d85eab1752ce3ebe3b6353f..b5940b4ad03231d4d6540e58d1d5d3597f1daae4 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/signal/test/EventSignalUtilTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/signal/test/EventSignalUtilTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.signal.test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -23,7 +24,6 @@ import org.eclipse.trace4cps.core.impl.Interval; import org.junit.jupiter.api.Test; public class EventSignalUtilTest { - @Test public void testInstantaneous() { List es = new ArrayList(); @@ -88,7 +88,7 @@ public class EventSignalUtilTest { public void testConvolution_large() { List es = new ArrayList(); for (int i = 0; i < 1000; i++) { - es.add(new LinearSignalFragment(i, (double) i + 0.2, 5)); + es.add(new LinearSignalFragment(i, (double)i + 0.2, 5)); } IPsop p = EventSignalUtil.convoluteScaleAndProject(es, 60, 30, new Interval(0, 1030)); assertEquals(0d, PsopHelper.getDomainLowerBound(p).doubleValue(), 1e-9); @@ -124,5 +124,4 @@ public class EventSignalUtilTest { EventSignalUtil.computeInstantaneous(es, 1, new Interval(0, 10)); }); } - } diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/signal/test/SignalUtilTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/signal/test/SignalUtilTest.java index 454467f08a929e10e8ee0dc9bcdf75a5435a3191..8ee9f659451397089cb260ff4e3a3534d73f550a 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/signal/test/SignalUtilTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/signal/test/SignalUtilTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.signal.test; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -33,7 +34,6 @@ import org.eclipse.trace4cps.core.impl.Trace; import org.junit.jupiter.api.Test; public class SignalUtilTest { - @Test public void testInstThroughputSignal() throws Exception { ITrace trace = createTestTrace(); @@ -60,7 +60,7 @@ public class SignalUtilTest { public void testThroughputSignalEvents() throws Exception { List events = getStartEvents(); // every 20 ms an event: 50 events per second IPsop tp = SignalUtil.getTP(TimeUnit.SECONDS, new Interval(0, 20), events, TimeUnit.SECONDS, 3001, - TimeUnit.MILLISECONDS); + TimeUnit.MILLISECONDS); // At most 151 events in the window of 3001 ms assertMaxValue(tp, 151d / 3.001); assertMinValue(tp, 0); @@ -89,7 +89,7 @@ public class SignalUtilTest { ITrace trace = createTestTrace(); IPsop p = SignalUtil.getLatency(trace, "id", TimeUnit.MILLISECONDS, 0, TimeUnit.SECONDS); // check that every fragment is valid - for (IPsopFragment f : p.getFragments()) { + for (IPsopFragment f: p.getFragments()) { double a = f.getA().doubleValue(); double b = f.getB().doubleValue(); double c = f.getC().doubleValue(); @@ -107,7 +107,7 @@ public class SignalUtilTest { ITrace trace = createTestTrace(); IPsop p = SignalUtil.getLatency(trace, "id", TimeUnit.MILLISECONDS, 3, TimeUnit.SECONDS); // check that every fragment is valid - for (IPsopFragment f : p.getFragments()) { + for (IPsopFragment f: p.getFragments()) { double a = f.getA().doubleValue(); double b = f.getB().doubleValue(); double c = f.getC().doubleValue(); @@ -182,8 +182,8 @@ public class SignalUtilTest { private List getStartEvents() { List events = new ArrayList<>(); - for (IEvent e : createTestTrace().getEvents()) { - if (((IClaimEvent) e).getType() == ClaimEventType.START) { + for (IEvent e: createTestTrace().getEvents()) { + if (((IClaimEvent)e).getType() == ClaimEventType.START) { events.add(e); } } diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/stl/test/PsopBuilder.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/stl/test/PsopBuilder.java index 140967310cbc0b0c48af8f63203dcd47f49720f0..33887af91c87633463cd4ff4aaf6141a374b9977 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/stl/test/PsopBuilder.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/stl/test/PsopBuilder.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.stl.test; import org.eclipse.trace4cps.core.impl.Interval; @@ -14,7 +15,6 @@ import org.eclipse.trace4cps.core.impl.Psop; import org.eclipse.trace4cps.core.impl.PsopFragment; public class PsopBuilder { - private double x0; private double v0; diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/stl/test/PsopFragmentTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/stl/test/PsopFragmentTest.java index f0ef780aa222d9cc5b2073060e791571fa94efe3..d718aa4ce4bb2882d1afb5f72f767e25bee2b6f1 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/stl/test/PsopFragmentTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/stl/test/PsopFragmentTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.stl.test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -24,19 +25,14 @@ import org.eclipse.trace4cps.core.impl.PsopFragment; import org.junit.jupiter.api.Test; public class PsopFragmentTest { - @Test public void testCtorInvalid1() { - assertThrows(IllegalArgumentException.class, () -> { - new PsopFragment(0d, 1, -2, null); - }); + assertThrows(IllegalArgumentException.class, () -> { new PsopFragment(0d, 1, -2, null); }); } @Test public void testCtorInvalid2() { - assertThrows(IllegalArgumentException.class, () -> { - new PsopFragment(0d, 1, -2, new Interval(10, 5)); - }); + assertThrows(IllegalArgumentException.class, () -> { new PsopFragment(0d, 1, -2, new Interval(10, 5)); }); } @Test @@ -89,9 +85,8 @@ public class PsopFragmentTest { @Test public void testTimeZeroSlopeIllegal() { - assertThrows(IllegalArgumentException.class, () -> { - PsopHelper.argZeroSlope(new PsopFragment(0d, 2, 0d, new Interval(0, 4))); - }); + assertThrows(IllegalArgumentException.class, + () -> { PsopHelper.argZeroSlope(new PsopFragment(0d, 2, 0d, new Interval(0, 4))); }); } @Test diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/stl/test/PsopTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/stl/test/PsopTest.java index 17b44d3df187c98db7c950a2f7fc3e40a4ac4214..aee11d3ee8c76934e5fd88657279d01d70a929c9 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/stl/test/PsopTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/stl/test/PsopTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.stl.test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -27,12 +28,9 @@ import org.eclipse.trace4cps.core.impl.PsopFragment; import org.junit.jupiter.api.Test; public class PsopTest { - @Test public void testDomInvalid() { - assertThrows(IllegalStateException.class, () -> { - PsopHelper.dom(new Psop()); - }); + assertThrows(IllegalStateException.class, () -> { PsopHelper.dom(new Psop()); }); } @Test @@ -52,9 +50,7 @@ public class PsopTest { @Test public void testValueAtInvalid() { - assertThrows(IllegalArgumentException.class, () -> { - PsopHelper.valueAt(getTestFunction1(), 100); - }); + assertThrows(IllegalArgumentException.class, () -> { PsopHelper.valueAt(getTestFunction1(), 100); }); } @Test @@ -202,7 +198,7 @@ public class PsopTest { IPsop pb = PsopHelper.sub(p2, p1); assertEquals(1, pb.getFragments().size()); assertFragment(pb.getFragments().get(0), 0d, 1d, 1d, -2d, 0d); -} + } @Test public void testCreateMonotonicSegmentations() { @@ -265,7 +261,7 @@ public class PsopTest { public static void assertTimeDomains(IPsop f, double... ts) { int i = 0; - for (IPsopFragment frag : f.getFragments()) { + for (IPsopFragment frag: f.getFragments()) { assertEquals(ts[i], frag.dom().lb().doubleValue(), 1e-9); assertEquals(ts[i + 1], frag.dom().ub().doubleValue(), 1e-9); i++; @@ -302,5 +298,4 @@ public class PsopTest { b.addFragment(0, 4); return b.get(); } - } diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/stl/test/StlBuilderTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/stl/test/StlBuilderTest.java index 572d3744650eb703bc326b8380dfeb54ea770811..465919050d991702b434a34cb82dcb6fa6f803f6 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/stl/test/StlBuilderTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/stl/test/StlBuilderTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.stl.test; import static org.eclipse.trace4cps.analysis.stl.StlBuilder.AND; @@ -34,7 +35,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; public class StlBuilderTest { - private ITrace traceOdse; @BeforeEach @@ -45,8 +45,7 @@ public class StlBuilderTest { @Test public void testResourceAmountODSE() { IResource m2 = TraceHelper.filter(traceOdse.getResources(), "name", "M2").get(0); - IPsop p = - SignalUtil.getResourceAmount(traceOdse, m2, new SignalModifier(1, 10, TimeUnit.MILLISECONDS)); + IPsop p = SignalUtil.getResourceAmount(traceOdse, m2, new SignalModifier(1, 10, TimeUnit.MILLISECONDS)); // We know the trace time domain is approx [0, 1600] ms StlFormula phi = G(AND(LEQ(p, 90), GEQ(p, 10)), 100, 1500); assertTrue(phi.getRho() > 0d); @@ -61,8 +60,7 @@ public class StlBuilderTest { @Test public void testResourceClientODSE() { IResource m2 = TraceHelper.filter(traceOdse.getResources(), "name", "M2").get(0); - IPsop p = - SignalUtil.getResourceClients(traceOdse, m2, new SignalModifier(1, 10, TimeUnit.MILLISECONDS)); + IPsop p = SignalUtil.getResourceClients(traceOdse, m2, new SignalModifier(1, 10, TimeUnit.MILLISECONDS)); // We know the trace time domain is approx [0, 1600] ms StlFormula phi = G(AND(LEQ(p, 6), GEQ(p, 1)), 100, 1500); assertTrue(phi.getRho() > 0d); diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/stl/test/StlUtilTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/stl/test/StlUtilTest.java index 1b22b8e6e316009ae1ba3e2df31a3b918e5a8419..20758210615757ea9ef5e52847eb24e1fdb5d6c8 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/stl/test/StlUtilTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/stl/test/StlUtilTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.stl.test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -20,10 +21,9 @@ import org.eclipse.trace4cps.core.impl.PsopFragment; import org.junit.jupiter.api.Test; public class StlUtilTest { - /** * CAV 2013 paper, Donze, Ferrere, Maler. - * + * * @throws Exception */ @Test @@ -79,7 +79,7 @@ public class StlUtilTest { assertEquals(10d, PsopHelper.getStartValue(f).doubleValue(), 1e-9); assertEquals(-20d, PsopHelper.getMinValue(f).doubleValue(), 1e-9); assertEquals(12d, PsopHelper.getMaxValue(f).doubleValue(), 1e-9); - + IPsop g1 = STLUtil.signal_eventually(f, 0, 20); assertEquals(12d, PsopHelper.getMaxValue(g1).doubleValue(), 1e-9); IPsop g2 = STLUtil.signal_eventually(f, 5, Double.POSITIVE_INFINITY); diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/timing/test/StatisticsManagerTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/timing/test/StatisticsManagerTest.java index aa46e4bdac41189c28ddcb764a149016659d96e7..7c3c8dfacb33d8ade6936b3e13e260994c3dd559 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/timing/test/StatisticsManagerTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/analysis/timing/test/StatisticsManagerTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.timing.test; import java.util.concurrent.TimeUnit; @@ -16,7 +17,6 @@ import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; public class StatisticsManagerTest { - @Test public void testScale1() { StatisticsManager m = new StatisticsManager(TimeUnit.SECONDS); @@ -35,7 +35,6 @@ public class StatisticsManagerTest { Assertions.assertEquals(TimeUnit.SECONDS, m.getTimeUnit()); } - @Test public void testAutoScale1() { StatisticsManager m = new StatisticsManager(TimeUnit.MILLISECONDS); diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/AttributeAwareTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/AttributeAwareTest.java index d94cbe21909831d75050a425f0c8e14ef057e31c..ae868ecc100405882a10880b18ab7d2664fccb52 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/AttributeAwareTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/AttributeAwareTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.impl.test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -17,9 +18,7 @@ import java.util.Map; import org.eclipse.trace4cps.core.impl.AttributeAware; import org.junit.jupiter.api.Test; - public class AttributeAwareTest { - @Test public void testSetGet() { AttributeAware a = new AttributeAware(); @@ -56,5 +55,4 @@ public class AttributeAwareTest { a.setAttribute("a", "1\n2"); assertEquals("1 2", a.getAttributeValue("a")); } - } diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/ClaimEventTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/ClaimEventTest.java index 4d77a5e0d301268a8cfa4b2f0ee4db87e30781c0..725ebeeae27087816cd5f841657fdc5eec3ed6e7 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/ClaimEventTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/ClaimEventTest.java @@ -7,10 +7,12 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.impl.test; import static org.junit.jupiter.api.Assertions.assertEquals; -import static org.junit.jupiter.api.Assertions.*; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.HashMap; import java.util.Map; @@ -25,7 +27,6 @@ import org.eclipse.trace4cps.core.impl.Resource; import org.junit.jupiter.api.Test; public class ClaimEventTest { - @Test public void testGetType() throws TraceException { IResource r = new Resource(10, false); diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/ClaimTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/ClaimTest.java index 5b155e29d98b8d6a9e1239788d586dd12c8fd99b..3eac987e5a871b3b764d31009377f0bfa5d94762 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/ClaimTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/ClaimTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.impl.test; import static org.junit.jupiter.api.Assertions.assertNotNull; @@ -18,51 +19,42 @@ import org.eclipse.trace4cps.core.impl.Resource; import org.junit.jupiter.api.Test; public class ClaimTest { - @Test - public void testClaimCtor1() { + public void testClaimCtor1() { IResource r = new Resource(1, false); Claim c = new Claim(0, 10, r, 0.2); assertNotNull(c); } @Test - public void testClaimCtor2() { + public void testClaimCtor2() { IResource r = new Resource(1, true); Claim c = new Claim(0, 10, r, 0.1, 0.2); assertNotNull(c); } @Test - public void testClaimCtorInvalid1() { + public void testClaimCtorInvalid1() { IResource r = new Resource(1, true); - assertThrows(IllegalArgumentException.class, () -> { - new Claim(0, 10, r, 0.2); - }); + assertThrows(IllegalArgumentException.class, () -> { new Claim(0, 10, r, 0.2); }); } @Test - public void testClaimCtorInvalid2() { + public void testClaimCtorInvalid2() { IResource r = new Resource(1, false); - assertThrows(IllegalArgumentException.class, () -> { - new Claim(0, 10, r, 0.1, 0.2); - }); + assertThrows(IllegalArgumentException.class, () -> { new Claim(0, 10, r, 0.1, 0.2); }); } @Test - public void testClaimCtorInvalid3() { + public void testClaimCtorInvalid3() { IResource r = new Resource(1, false); - assertThrows(IllegalArgumentException.class, () -> { - new Claim(20, 10, r, 0.2); - }); + assertThrows(IllegalArgumentException.class, () -> { new Claim(20, 10, r, 0.2); }); } @Test - public void testClaimCtorInvalid4() { + public void testClaimCtorInvalid4() { IResource r = new Resource(1, true); - assertThrows(IllegalArgumentException.class, () -> { - new Claim(10, 20, r, 2.3, 0.2); - }); + assertThrows(IllegalArgumentException.class, () -> { new Claim(10, 20, r, 2.3, 0.2); }); } @Test diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/EventTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/EventTest.java index ac23f9615323bf03cefbf81a6348d6761cf094fa..cf91d77cde3bae51032e1acc6df769ad494687d2 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/EventTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/EventTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.impl.test; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -18,7 +19,6 @@ import org.eclipse.trace4cps.core.impl.Event; import org.junit.jupiter.api.Test; public class EventTest { - @Test public void testSatisfies() { Event e = new Event(10d); diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/IntervalTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/IntervalTest.java index a83776e2079336f63a7964933d0e88e745c16ba2..152ceb3d413e774f1d7250fe465cd01f3f7866f9 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/IntervalTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/IntervalTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.impl.test; import static org.junit.jupiter.api.Assertions.assertFalse; @@ -17,7 +18,6 @@ import org.eclipse.trace4cps.core.impl.Interval; import org.junit.jupiter.api.Test; public class IntervalTest { - @Test public void testIntervalConstruction1() { assertNotNull(new Interval(0, 10)); @@ -27,8 +27,8 @@ public class IntervalTest { @Test public void testEmpty() { - assertTrue(new Interval(4,3).isEmpty()); - assertTrue(new Interval(4,4).isEmpty()); + assertTrue(new Interval(4, 3).isEmpty()); + assertTrue(new Interval(4, 4).isEmpty()); assertFalse(new Interval(4, false, 4, false).isEmpty()); } diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/ModifiableTraceTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/ModifiableTraceTest.java index df5f78e89e5bb18ad887c7ae6b84d5e732b95985..d1103fe0c27a8b08ab529bb9d997eb7db7535aaa 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/ModifiableTraceTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/ModifiableTraceTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.impl.test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -38,7 +39,6 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; public class ModifiableTraceTest { - private IEvent ex1, ex2; private ModifiableTrace t; @@ -329,7 +329,6 @@ public class ModifiableTraceTest { } private static final class NameFilter implements IAttributeFilter { - private final String value; public NameFilter(String v) { diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/PsopFragmentTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/PsopFragmentTest.java index 605059439662d32e39c92015ce1e17900e87e067..9eae8529a078e1ed3ded26e774d9c12841d57405 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/PsopFragmentTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/PsopFragmentTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.impl.test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -19,7 +20,6 @@ import org.eclipse.trace4cps.core.impl.PsopFragment; import org.junit.jupiter.api.Test; public class PsopFragmentTest { - @Test public void testCtor() { PsopFragment f = new PsopFragment(10, 20, 30, new Interval(0, 1)); @@ -27,38 +27,29 @@ public class PsopFragmentTest { } @Test - public void testCtorInvalid1() { - assertThrows(IllegalArgumentException.class, () -> { - new PsopFragment(10, 20, 30, new Interval(0, true, 1, true)); - }); + public void testCtorInvalid1() { + assertThrows(IllegalArgumentException.class, + () -> { new PsopFragment(10, 20, 30, new Interval(0, true, 1, true)); }); } @Test - public void testCtorInvalid2() { - assertThrows(IllegalArgumentException.class, () -> { - new PsopFragment(null, 20, 30, new Interval(0, 1)); - }); + public void testCtorInvalid2() { + assertThrows(IllegalArgumentException.class, () -> { new PsopFragment(null, 20, 30, new Interval(0, 1)); }); } @Test - public void testCtorInvalid3() { - assertThrows(IllegalArgumentException.class, () -> { - new PsopFragment(10, null, 30, new Interval(0, 1)); - }); + public void testCtorInvalid3() { + assertThrows(IllegalArgumentException.class, () -> { new PsopFragment(10, null, 30, new Interval(0, 1)); }); } @Test public void testCtorInvalid4() { - assertThrows(IllegalArgumentException.class, () -> { - new PsopFragment(10, 20, null, new Interval(0, 1)); - }); + assertThrows(IllegalArgumentException.class, () -> { new PsopFragment(10, 20, null, new Interval(0, 1)); }); } @Test public void testCtorInvalid5() { - assertThrows(IllegalArgumentException.class, () -> { - new PsopFragment(10, 20, 30, new Interval(0, -1)); - }); + assertThrows(IllegalArgumentException.class, () -> { new PsopFragment(10, 20, 30, new Interval(0, -1)); }); } @Test diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/PsopTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/PsopTest.java index 70f3eb44c41fa99a03268c9ca8aa4264efa4a554..af0b153e2f13336a67d94cd055319d987c3b0f39 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/PsopTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/PsopTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.impl.test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -18,7 +19,6 @@ import org.eclipse.trace4cps.core.impl.PsopFragment; import org.junit.jupiter.api.Test; public class PsopTest { - @Test public void testAdd() { Psop p = new Psop(); @@ -39,18 +39,16 @@ public class PsopTest { public void testAddInvalid1() { Psop p = new Psop(); p.add(new PsopFragment(10, 20, 30, new Interval(0, 1))); - assertThrows(IllegalArgumentException.class, () -> { - p.add(new PsopFragment(10, 20, 30, new Interval(2, 3))); - }); + assertThrows(IllegalArgumentException.class, + () -> { p.add(new PsopFragment(10, 20, 30, new Interval(2, 3))); }); } @Test public void testAddInvalid2() { Psop p = new Psop(); p.add(new PsopFragment(10, 20, 30, new Interval(0, 1))); - assertThrows(IllegalArgumentException.class, () -> { - p.addAtBegin(new PsopFragment(10, 20, 30, new Interval(-2, -1))); - }); + assertThrows(IllegalArgumentException.class, + () -> { p.addAtBegin(new PsopFragment(10, 20, 30, new Interval(-2, -1))); }); } @Test @@ -89,5 +87,4 @@ public class PsopTest { p.merge(); assertEquals(2, p.getFragments().size()); // not merged } - } diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/ResourceTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/ResourceTest.java index edb15c924042cb23118624949d1d569c87f9e51b..f84575f7441e72b2c01c0f24761f094f28d0b49d 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/ResourceTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/ResourceTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.impl.test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -16,7 +17,6 @@ import org.eclipse.trace4cps.core.impl.Resource; import org.junit.jupiter.api.Test; public class ResourceTest { - @Test public void testNormal() { Resource r = new Resource(10, true); @@ -26,8 +26,6 @@ public class ResourceTest { @Test public void testInvalid() { - assertThrows(IllegalArgumentException.class, () -> { - new Resource(0d, true); - }); + assertThrows(IllegalArgumentException.class, () -> { new Resource(0d, true); }); } } diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/TraceTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/TraceTest.java index f7635e6926db6436a3a36b922aeddf107d3971cd..6c9e3b4e28370d99d636d2d9703c917343a227e5 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/TraceTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/impl/test/TraceTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.impl.test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -20,21 +21,20 @@ import org.eclipse.trace4cps.core.impl.Trace; import org.junit.jupiter.api.Test; public class TraceTest { - @Test public void testTraceTimeUnit() { Trace t = new Trace(); assertEquals(TimeUnit.SECONDS, t.getTimeUnit()); - assertEquals(0l, t.getTimeOffset()); + assertEquals(0L, t.getTimeOffset()); } @Test public void testTimeOffset() { Trace t = new Trace(); t.setTimeUnit(TimeUnit.MICROSECONDS); - t.setOffset(-10l); + t.setOffset(-10L); assertEquals(TimeUnit.MICROSECONDS, t.getTimeUnit()); - assertEquals(-10l, t.getTimeOffset()); + assertEquals(-10L, t.getTimeOffset()); } @Test diff --git a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/io/test/TraceIOTest.java b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/io/test/TraceIOTest.java index c8f50345537721a3a609acfd3179b93f72776d15..127aa498f78a2bc51b156093d5517960f324ff8b 100644 --- a/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/io/test/TraceIOTest.java +++ b/trace/org.eclipse.trace4cps.core.tests/src/org/eclipse/trace4cps/core/io/test/TraceIOTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.io.test; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -38,7 +39,6 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; public class TraceIOTest { - private static ITrace t; @BeforeAll @@ -54,7 +54,7 @@ public class TraceIOTest { @Test public void testTimeUnitAndOffset() throws Exception { assertEquals(TimeUnit.MILLISECONDS, t.getTimeUnit()); - assertEquals(10283l, t.getTimeOffset()); + assertEquals(10283L, t.getTimeOffset()); } @Test @@ -150,8 +150,7 @@ public class TraceIOTest { @Test public void testReadPsopNonConsecutiveFragments() { assertThrows(ParseException.class, () -> { - String testPsop = - "S 0;signal=S0 \nF 0 14.5 14.6 6.0 0.0 0.0\nF 0 14.7 14.8 6.0 0.0 0.0\n"; + String testPsop = "S 0;signal=S0 \nF 0 14.5 14.6 6.0 0.0 0.0\nF 0 14.7 14.8 6.0 0.0 0.0\n"; TraceReader.readTrace(testPsop); }); } @@ -174,13 +173,13 @@ public class TraceIOTest { private void assertClaims(ITrace trace) { List claims = trace.getClaims(); assertEquals(2, claims.size()); - assertClaim(claims.get(0), 0.2, 13.2, TraceHelper.get(trace.getResources(), "name", "CPU"), - Double.NaN, 100); + assertClaim(claims.get(0), 0.2, 13.2, TraceHelper.get(trace.getResources(), "name", "CPU"), Double.NaN, 100); assertClaim(claims.get(1), 0.4, 0.6, TraceHelper.get(trace.getResources(), "name", "RAM"), 128, 256); } private void assertClaim(IClaim claim, double t0, double t1, IResource r, double offset, double amount, - String... att) { + String... att) + { assertEquals(r, claim.getResource()); assertEquals(t0, claim.getStartTime().doubleValue(), 1e-9); assertEquals(t1, claim.getEndTime().doubleValue(), 1e-9); @@ -225,10 +224,10 @@ public class TraceIOTest { assertTrue(e3 instanceof ClaimEvent); assertFalse(e4 instanceof ClaimEvent); assertFalse(e5 instanceof ClaimEvent); - assertEquals(trace.getClaims().get(0), ((ClaimEvent) e0).getClaim()); - assertEquals(trace.getClaims().get(1), ((ClaimEvent) e1).getClaim()); - assertEquals(trace.getClaims().get(1), ((ClaimEvent) e2).getClaim()); - assertEquals(trace.getClaims().get(0), ((ClaimEvent) e3).getClaim()); + assertEquals(trace.getClaims().get(0), ((ClaimEvent)e0).getClaim()); + assertEquals(trace.getClaims().get(1), ((ClaimEvent)e1).getClaim()); + assertEquals(trace.getClaims().get(1), ((ClaimEvent)e2).getClaim()); + assertEquals(trace.getClaims().get(0), ((ClaimEvent)e3).getClaim()); } private void assertDependencies(ITrace t) { @@ -246,8 +245,8 @@ public class TraceIOTest { assertTrue(d0.getSrc() instanceof ClaimEvent); assertTrue(d0.getDst() instanceof ClaimEvent); - assertEquals(((ClaimEvent) d0.getSrc()).getClaim(), c0); - assertEquals(((ClaimEvent) d0.getDst()).getClaim(), c1); + assertEquals(((ClaimEvent)d0.getSrc()).getClaim(), c0); + assertEquals(((ClaimEvent)d0.getDst()).getClaim(), c1); assertFalse(d1.getSrc() instanceof ClaimEvent); assertFalse(d1.getDst() instanceof ClaimEvent); @@ -256,7 +255,7 @@ public class TraceIOTest { assertTrue(d2.getSrc() instanceof ClaimEvent); assertFalse(d2.getDst() instanceof ClaimEvent); - assertEquals(((ClaimEvent) d2.getSrc()).getClaim(), c0); + assertEquals(((ClaimEvent)d2.getSrc()).getClaim(), c0); assertEquals(d2.getDst(), e0); } diff --git a/trace/org.eclipse.trace4cps.core/.checkstyle b/trace/org.eclipse.trace4cps.core/.checkstyle new file mode 100644 index 0000000000000000000000000000000000000000..b01fc54c7363d48a5fce265944ff35f3519d22f6 --- /dev/null +++ b/trace/org.eclipse.trace4cps.core/.checkstyle @@ -0,0 +1,7 @@ + + + + + + + diff --git a/trace/org.eclipse.trace4cps.core/.project b/trace/org.eclipse.trace4cps.core/.project index 38b022649bb459e3c6988457a7e7537adb2c6f80..26ec916b107849fd7c3e7d8edd332e58b8ee77ae 100644 --- a/trace/org.eclipse.trace4cps.core/.project +++ b/trace/org.eclipse.trace4cps.core/.project @@ -20,9 +20,15 @@ + + net.sf.eclipsecs.core.CheckstyleBuilder + + + org.eclipse.pde.PluginNature org.eclipse.jdt.core.javanature + net.sf.eclipsecs.core.CheckstyleNature diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/AnalysisException.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/AnalysisException.java index 6ecc40f1023dc19a46ed9ee880f1aa8a498b13cf..c570287c09be9dc19d26983223176693b4589c15 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/AnalysisException.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/AnalysisException.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis; import org.eclipse.trace4cps.core.TraceException; @@ -15,7 +16,6 @@ import org.eclipse.trace4cps.core.TraceException; * Top-level exception for the TRACE analysis packages. */ public class AnalysisException extends TraceException { - private static final long serialVersionUID = 1L; public AnalysisException() { diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/behavior/Behavior.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/behavior/Behavior.java index fcb1d3c1130dcaa5f1ec88188b47de97cb656e02..94d9447bd9f5b8354ce8dd4de6f66374add253f6 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/behavior/Behavior.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/behavior/Behavior.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.behavior; import java.util.ArrayList; @@ -20,11 +21,10 @@ import org.eclipse.trace4cps.analysis.dist.DistanceAnalysis; import org.eclipse.trace4cps.core.IEvent; /** - * A behavior is a set of {@link IEvent} instances with the same value for the given {@code idAtt} attribute. - * Such a set of event models, for instance, the processing of a single image with a certain id. + * A behavior is a set of {@link IEvent} instances with the same value for the given {@code idAtt} attribute. Such a set + * of event models, for instance, the processing of a single image with a certain id. */ public final class Behavior { - private final String idAtt; private final int idVal; diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/behavior/BehavioralAnalysis.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/behavior/BehavioralAnalysis.java index ee951874cd569810e051709294e364d431dc848d..edc86f199addbd9d4f04c5a95fa5fb1e47f01092 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/behavior/BehavioralAnalysis.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/behavior/BehavioralAnalysis.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.behavior; import java.util.ArrayList; @@ -18,49 +19,45 @@ import java.util.Set; import org.eclipse.trace4cps.core.IAttributeAware; import org.eclipse.trace4cps.core.IAttributeFilter; +import org.eclipse.trace4cps.core.IClaimEvent; import org.eclipse.trace4cps.core.IEvent; /** * This is the top-level accessor for the functionality in this package. */ public class BehavioralAnalysis { - private BehavioralAnalysis() { } /** - * Creates a partition of the behavior for the attribute {@code idAtt}. It is assumed that each - * {@link IEvent} has an integer value for this attribute. Furthermore, some sequential process is - * assumed. Events with lower values for the attribute happen before (more or less) events with a higher - * value for the attribute. An example is image processing in which each event is associated with - * processing a frame with a certain (increasing) id. - * + * Creates a partition of the behavior for the attribute {@code idAtt}. It is assumed that each {@link IEvent} has + * an integer value for this attribute. Furthermore, some sequential process is assumed. Events with lower values + * for the attribute happen before (more or less) events with a higher value for the attribute. An example is image + * processing in which each event is associated with processing a frame with a certain (increasing) id. + * * @param events the events to consider for the partition * @param idAtt the ID attribute: each event should have an integer value for it * @param uniquenessAtts the attributes that together with the {@code idAtt} and the resource (in case of - * {@link IClaimEvent} instances) make events unique + * {@link IClaimEvent} instances) make events unique * @return a {@link BehavioralPartition} */ - public static BehavioralPartition partition(Iterable events, String idAtt, - Set uniquenessAtts) { + public static BehavioralPartition partition(Iterable events, String idAtt, Set uniquenessAtts) { return new BehavioralPartition(events, idAtt, uniquenessAtts); } /** - * Creates a histogram for a given behavioral partition. The histogram entries are sorted w.r.t. size - * (decreasing). - * + * Creates a histogram for a given behavioral partition. The histogram entries are sorted w.r.t. size (decreasing). + * * @param partition the behavioral partition for which to create a histogram * @return the histogram */ public static List createBehavioralHistogram(BehavioralPartition partition) { List entries = new ArrayList(); - for (List cell : partition) { + for (List cell: partition) { entries.add(new HistogramEntry(cell)); } // sort by cell size (largest first) Collections.sort(entries, new Comparator() { - @Override public int compare(HistogramEntry o1, HistogramEntry o2) { return Integer.compare(o2.size(), o1.size()); @@ -71,22 +68,21 @@ public class BehavioralAnalysis { /** * Computes a filter that only shows the representative events for a partition. - * + * * @param partition a behavioral partition - * @return a filter for {@link IEvent} instances that only shows one representative for each cell in the - * given partition + * @return a filter for {@link IEvent} instances that only shows one representative for each cell in the given + * partition */ public static IAttributeFilter computeBehavioralRepresentativeFilter(BehavioralPartition partition) { if (partition.size() == 0) { return null; } final Set objectIds = new HashSet(); - for (Behavior b : partition.getRepresentatives()) { + for (Behavior b: partition.getRepresentatives()) { objectIds.add(b.getValue()); } final String idAtt = partition.getIdAtt(); return new IAttributeFilter() { - @Override public boolean include(IAttributeAware a) { String id = a.getAttributeValue(idAtt); diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/behavior/BehavioralPartition.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/behavior/BehavioralPartition.java index e2c64fbd58e3f7da50b62b5d2cb41add7f2dcd4f..908d2daf41273a8c308aaf79237706038b084e70 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/behavior/BehavioralPartition.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/behavior/BehavioralPartition.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.behavior; import java.util.ArrayList; @@ -21,15 +22,13 @@ import java.util.Set; import org.eclipse.trace4cps.core.IEvent; /** - * A behavioral partition is a partition of a set of {@link Behavior} instances. It is assumed that there is a - * certain attribute, the {@code idAtt}, for which every {@link IEvent} has an integer value. This can be, for - * instance, the frame id in an image processing application, the sheet id in a print job, etc. All - * {@link IEvent} instances with the same value for this {@code idAtt} form a single {@link Behavior} - * instance. The equivalence between two behaviors, which is used to create the partition, is given by the - * zero-distance between the sets of {@link IEvent} instances. + * A behavioral partition is a partition of a set of {@link Behavior} instances. It is assumed that there is a certain + * attribute, the {@code idAtt}, for which every {@link IEvent} has an integer value. This can be, for instance, the + * frame id in an image processing application, the sheet id in a print job, etc. All {@link IEvent} instances with the + * same value for this {@code idAtt} form a single {@link Behavior} instance. The equivalence between two behaviors, + * which is used to create the partition, is given by the zero-distance between the sets of {@link IEvent} instances. */ public class BehavioralPartition implements Iterable> { - private final String idAtt; private final Set uniquenessAtts; @@ -95,7 +94,7 @@ public class BehavioralPartition implements Iterable> { Behavior b = bl.get(i); // Find a cell to which it belongs, if exists boolean found = false; - for (Map.Entry> e : freq.entrySet()) { + for (Map.Entry> e: freq.entrySet()) { if (b.distanceTo(e.getKey(), uniquenessAtts) == 0) { e.getValue().add(b); found = true; @@ -122,7 +121,7 @@ public class BehavioralPartition implements Iterable> { objectId2Behavior.put(theObjectId, b); } // Add the events to the behaviors: - for (IEvent event : events) { + for (IEvent event: events) { Integer id = getId(event); Behavior b = objectId2Behavior.get(id); b.add(event); @@ -131,7 +130,7 @@ public class BehavioralPartition implements Iterable> { } private boolean validateObjectId(Iterable events, String idAtt) { - for (IEvent e : events) { + for (IEvent e: events) { String val = e.getAttributeValue(idAtt); if (val == null || !isInteger(val)) { return false; @@ -156,7 +155,7 @@ public class BehavioralPartition implements Iterable> { */ private List getObjectIds(Iterable events) { Set ids = new HashSet(); - for (IEvent c : events) { + for (IEvent c: events) { Integer v = getId(c); if (v != null) { ids.add(v); diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/behavior/HistogramEntry.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/behavior/HistogramEntry.java index 759ac8b8ecf2a3b71c12eba1e6b0a294cfa896da..c1ea764f95ee13c245afab72fa72486ff6d9f6d2 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/behavior/HistogramEntry.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/behavior/HistogramEntry.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.behavior; import java.util.ArrayList; @@ -20,11 +21,10 @@ import java.util.Set; import org.eclipse.trace4cps.core.IEvent; /** - * A histogram entry for a cell from a behavioral partition. It computes the common attribute-value pairs in - * all the events of the cell. + * A histogram entry for a cell from a behavioral partition. It computes the common attribute-value pairs in all the + * events of the cell. */ public class HistogramEntry { - private final Map common = new HashMap(); private final Set objectIds = new HashSet(); @@ -33,13 +33,13 @@ public class HistogramEntry { HistogramEntry(List cell) { size = cell.size(); - for (Behavior b : cell) { + for (Behavior b: cell) { objectIds.add(b.getValue()); } // Compute the common attribute-value pairs boolean first = true; - for (Behavior b : cell) { - for (IEvent e : b.getEvents()) { + for (Behavior b: cell) { + for (IEvent e: b.getEvents()) { if (first) { common.putAll(e.getAttributes()); first = false; @@ -55,12 +55,12 @@ public class HistogramEntry { private void intersectAttributes(IEvent event) { List keysToRemove = new ArrayList(); - for (Map.Entry e : common.entrySet()) { + for (Map.Entry e: common.entrySet()) { if (!e.getValue().equals(event.getAttributeValue(e.getKey()))) { keysToRemove.add(e.getKey()); } } - for (String k : keysToRemove) { + for (String k: keysToRemove) { common.remove(k); } } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/behavior/impl/FilteringClaimRepresentation.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/behavior/impl/FilteringClaimRepresentation.java index d52471387df1ec65dd0d5f14d153a56037bf841d..ef8d2cdd35f5c7e40b628e3b9bf5c9647228344b 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/behavior/impl/FilteringClaimRepresentation.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/behavior/impl/FilteringClaimRepresentation.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.behavior.impl; import java.util.ArrayList; @@ -15,6 +16,7 @@ import java.util.Comparator; import java.util.List; import java.util.Map; import java.util.Map.Entry; +import java.util.Set; import org.eclipse.trace4cps.analysis.dist.Representation; import org.eclipse.trace4cps.core.ClaimEventType; @@ -23,32 +25,26 @@ import org.eclipse.trace4cps.core.IEvent; import org.eclipse.trace4cps.core.impl.ClaimEvent; import org.eclipse.trace4cps.core.impl.TraceHelper; -import java.util.Set; - /** * This representation replaces the value of the attribute given on construction according to the given map. - * Furthermore, the string representation includes the id attribute (with the newly mapped value), the - * resource attributes, and the uniqueness attributes. + * Furthermore, the string representation includes the id attribute (with the newly mapped value), the resource + * attributes, and the uniqueness attributes. */ public final class FilteringClaimRepresentation implements Representation { - private final String idAtt; private final Set uniquenessAtts; private final Map idRemapping; - private static final Comparator> COMP = - new Comparator>() { - - @Override - public int compare(Entry o1, Entry o2) { - return o1.getKey().compareTo(o2.getKey()); - } - }; + private static final Comparator> COMP = new Comparator>() { + @Override + public int compare(Entry o1, Entry o2) { + return o1.getKey().compareTo(o2.getKey()); + } + }; - public FilteringClaimRepresentation(String idAtt, Set uniquenessAtts, - Map idRemapping) { + public FilteringClaimRepresentation(String idAtt, Set uniquenessAtts, Map idRemapping) { this.idAtt = idAtt; this.uniquenessAtts = uniquenessAtts; this.idRemapping = idRemapping; @@ -61,7 +57,7 @@ public final class FilteringClaimRepresentation implements Representation { List> le = new ArrayList>(); le.addAll(event.getAttributes().entrySet()); Collections.sort(le, COMP); - for (Map.Entry e : le) { + for (Map.Entry e: le) { String a = e.getKey(); String v = e.getValue(); if (!a.equals(idAtt) && (uniquenessAtts == null || uniquenessAtts.contains(a))) { @@ -72,7 +68,7 @@ public final class FilteringClaimRepresentation implements Representation { } } if (event instanceof IClaimEvent) { - ClaimEvent claimEvent = (ClaimEvent) event; + ClaimEvent claimEvent = (ClaimEvent)event; b.append("res={"); b.append(TraceHelper.getValues(claimEvent.getClaim().getResource(), true)); b.append("};"); diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/constraintgraph/ConstraintConfig.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/constraintgraph/ConstraintConfig.java index 94f04734c178e26da689f15f75af02789784580e..197f4b3bc12183c0ed3c2bea88937da5b08c9a4b 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/constraintgraph/ConstraintConfig.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/constraintgraph/ConstraintConfig.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.constraintgraph; import java.util.Map; @@ -16,23 +17,22 @@ import org.eclipse.trace4cps.core.IClaimEvent; import org.eclipse.trace4cps.core.IEvent; /** - * A configuration type that is used for building a {@code ConstraintGraph} from a set of {@link IEvent} - * instances. The {@code ConstraintGraph} is used by the critical-path analysis, and by the difference - * analysis methods, but the {@link ConstraintConfig} only appears on the API of the critical-path analysis. - * There are three heuristics that add timing constraints between {@link IEvent} instances: + * A configuration type that is used for building a {@code ConstraintGraph} from a set of {@link IEvent} instances. The + * {@code ConstraintGraph} is used by the critical-path analysis, and by the difference analysis methods, but the + * {@link ConstraintConfig} only appears on the API of the critical-path analysis. There are three heuristics that add + * timing constraints between {@link IEvent} instances: *
    *
  • Claim durations: adds constraints between the events of a single claim that model the duration of that * claim.
  • - *
  • Ordering heuristic: add a timing constraint {@code >= 0} from an end event to a start event if and only - * if the time gap between those is not negative (the start comes not earlier than the end), but not larger - * than a given {@code epsilon}.
  • - *
  • Non-elasticity heuristic: adds constraints between a set of events that fixes those exactly in time - * w.r.t. to each other. An {@code id} attribute is specified to partition the events, and a filter then is - * used to filter the events within a cell. The resulting set of events is fixed with timing constraints.
  • + *
  • Ordering heuristic: add a timing constraint {@code >= 0} from an end event to a start event if and only if the + * time gap between those is not negative (the start comes not earlier than the end), but not larger than a given + * {@code epsilon}.
  • + *
  • Non-elasticity heuristic: adds constraints between a set of events that fixes those exactly in time w.r.t. to + * each other. An {@code id} attribute is specified to partition the events, and a filter then is used to filter the + * events within a cell. The resulting set of events is fixed with timing constraints.
  • *
*/ public class ConstraintConfig { - private boolean addClaimLowerBoundConstraints = true; private boolean addClaimUpperBoundConstraints = true; @@ -62,7 +62,7 @@ public class ConstraintConfig { *
  • No ordering heuristic
  • *
  • No elasticity heuristic
  • * - * + * * @return the default configuration */ public static ConstraintConfig getDefault() { @@ -84,16 +84,16 @@ public class ConstraintConfig { } /** - * @return whether lower-bound constraints for claim durations are added between the two - * {@link IClaimEvent} instances that belong to the same {@link IClaim} + * @return whether lower-bound constraints for claim durations are added between the two {@link IClaimEvent} + * instances that belong to the same {@link IClaim} */ public boolean isAddClaimLowerBoundConstraints() { return addClaimLowerBoundConstraints; } /** - * @return whether upper-bound constraints for claim durations are added between the two - * {@link IClaimEvent} instances that belong to the same {@link IClaim} + * @return whether upper-bound constraints for claim durations are added between the two {@link IClaimEvent} + * instances that belong to the same {@link IClaim} */ public boolean isAddClaimUpperBoundConstraints() { return addClaimUpperBoundConstraints; @@ -149,7 +149,7 @@ public class ConstraintConfig { /** * Enables the non-elasticity heuristic for adding constraints between events with the given parameters. - * + * * @param filter the filter that is used to select a subset of events in a cell * @param partitioningAtt the attribute used to partition the events */ diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/constraintgraph/impl/ClaimNode.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/constraintgraph/impl/ClaimNode.java index 8279221f03e1c5f6adc3741117753bd136672447..2c82462aa5b907092c264502ae0e82d2a0160c32 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/constraintgraph/impl/ClaimNode.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/constraintgraph/impl/ClaimNode.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.constraintgraph.impl; import org.eclipse.trace4cps.core.ClaimEventType; @@ -14,28 +15,27 @@ import org.eclipse.trace4cps.core.IClaim; import org.eclipse.trace4cps.core.IClaimEvent; public class ClaimNode extends EventNode { - public ClaimNode(int id, IClaimEvent event) { super(id, event); } public IClaim getClaim() { - return ((IClaimEvent) getEvent()).getClaim(); + return ((IClaimEvent)getEvent()).getClaim(); } public boolean isClaimStart() { - return ((IClaimEvent) getEvent()).getType() == ClaimEventType.START; + return ((IClaimEvent)getEvent()).getType() == ClaimEventType.START; } public boolean isClaimStop() { - return ((IClaimEvent) getEvent()).getType() == ClaimEventType.END; + return ((IClaimEvent)getEvent()).getType() == ClaimEventType.END; } @Override public int compareTo(ConstraintGraphNode o) { int r = Double.compare(timestamp(), o.timestamp()); if (r == 0 && o instanceof ClaimNode) { - r = Boolean.compare(isClaimStart(), ((ClaimNode) o).isClaimStart()); + r = Boolean.compare(isClaimStart(), ((ClaimNode)o).isClaimStart()); } return r; } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/constraintgraph/impl/Constraint.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/constraintgraph/impl/Constraint.java index 80726f341ca2994350333f7f49852dfaa03d4a74..883b4fa84520f064af25c5dff9cc4453a6e0fbfa 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/constraintgraph/impl/Constraint.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/constraintgraph/impl/Constraint.java @@ -7,17 +7,17 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.constraintgraph.impl; /** - * A constraint {@code e1 -- w --> e2} gives a lower bound of {@code w} time units between the occurrence of - * {@code e1} and {@code e2}. - *

    + * A constraint {@code e1 -- w --> e2} gives a lower bound of {@code w} time units between the occurrence of {@code e1} + * and {@code e2}. + *

    * A constraint {@code e2 -- -w --> e1} gives an upper bound of {@code w} time units between the occurrence of * {@code e1} and {@code e2}. */ public class Constraint { - private final ConstraintGraphNode src; private final ConstraintGraphNode dst; @@ -40,9 +40,10 @@ public class Constraint { public final boolean isClaimDurationConstraint() { if (src instanceof ClaimNode && dst instanceof ClaimNode) { - ClaimNode e1 = (ClaimNode) src; - ClaimNode e2 = (ClaimNode) dst; - return ((e1.isClaimStart() && e2.isClaimStop() || (e2.isClaimStart() && e1.isClaimStop()))) && e1.getClaim() == e2.getClaim(); + ClaimNode e1 = (ClaimNode)src; + ClaimNode e2 = (ClaimNode)dst; + return ((e1.isClaimStart() && e2.isClaimStop() || (e2.isClaimStart() && e1.isClaimStop()))) + && e1.getClaim() == e2.getClaim(); } return false; } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/constraintgraph/impl/ConstraintGraph.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/constraintgraph/impl/ConstraintGraph.java index 552dfc30616d080a4ab53a76343d95d99cc2b02c..4d5bea68455cad8f6b30dad225d7ac2ea0f0c325 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/constraintgraph/impl/ConstraintGraph.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/constraintgraph/impl/ConstraintGraph.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.constraintgraph.impl; import java.util.ArrayList; @@ -43,10 +44,10 @@ public class ConstraintGraph { } /** - * Creates the core constraint graph from a set of claims. Only intra-claim constraints are added, i.e., - * the claim durations. Use {@link #applyOrderHeuristic(double)} and - * {@link #applyNonElasticityConstraint(Collection)} to add more constraints. - * + * Creates the core constraint graph from a set of claims. Only intra-claim constraints are added, i.e., the claim + * durations. Use {@link #applyOrderHeuristic(double)} and {@link #applyNonElasticityConstraint(Collection)} to add + * more constraints. + * * @param events the events for which to build a core constraint graph */ public ConstraintGraph(List events, List deps, ConstraintConfig config) { @@ -84,7 +85,7 @@ public class ConstraintGraph { public final int edgeSize() { int cnt = 0; - for (ConstraintGraphNode n : nodes) { + for (ConstraintGraphNode n: nodes) { cnt += n.constraints().size(); } return cnt; @@ -92,9 +93,9 @@ public class ConstraintGraph { private void createNodeList(List events, boolean addSourceAndSink) { int id = addSourceAndSink ? 1 : 0; - for (IEvent event : events) { + for (IEvent event: events) { if (event instanceof IClaimEvent) { - nodes.add(new ClaimNode(id, (IClaimEvent) event)); + nodes.add(new ClaimNode(id, (IClaimEvent)event)); } else { nodes.add(new EventNode(id, event)); } @@ -111,13 +112,14 @@ public class ConstraintGraph { // adds constraints w.r.t. the duration of claims for (int i = 0; i < nodes.size(); i++) { ConstraintGraphNode node = nodes.get(i); - if (node instanceof ClaimNode && ((ClaimNode) node).isClaimStart()) { - ClaimNode startNode = (ClaimNode) node; + if (node instanceof ClaimNode && ((ClaimNode)node).isClaimStart()) { + ClaimNode startNode = (ClaimNode)node; // find the end node: for (int j = findStartIndex(startNode, i); j < nodes.size(); j++) { ConstraintGraphNode nj = nodes.get(j); - if (nj instanceof ClaimNode && ((ClaimNode) nj).isClaimStop() - && ((ClaimNode) nj).getClaim() == startNode.getClaim()) { + if (nj instanceof ClaimNode && ((ClaimNode)nj).isClaimStop() + && ((ClaimNode)nj).getClaim() == startNode.getClaim()) + { double duration = nj.timestamp() - startNode.timestamp(); if (cfg.isAddClaimLowerBoundConstraints()) { startNode.addConstraint(nj, duration); @@ -145,10 +147,11 @@ public class ConstraintGraph { } private void applyNonElasticityConstraint(Map nonElasticGroupFilter, - String nonElasticGroupPartitioning) { - Collection> nonElasticCells = - computeNonElasticGroups(nonElasticGroupFilter, nonElasticGroupPartitioning); - for (List cell : nonElasticCells) { + String nonElasticGroupPartitioning) + { + Collection> nonElasticCells = computeNonElasticGroups(nonElasticGroupFilter, + nonElasticGroupPartitioning); + for (List cell: nonElasticCells) { Collections.sort(cell); // to be sure: sort by timestamp // The inter-event distances from claims in this cell are fixed and // given by the current timing @@ -163,11 +166,12 @@ public class ConstraintGraph { } } - private Collection> computeNonElasticGroups( - Map nonElasticGroupFilter, String nonElasticGroupPartitioning) { + private Collection> computeNonElasticGroups(Map nonElasticGroupFilter, + String nonElasticGroupPartitioning) + { Map> neg = new HashMap>(); - for (ConstraintGraphNode ce : nodes) { - EventNode eventNode = (EventNode) ce; // SrcSnk nodes not yet added! + for (ConstraintGraphNode ce: nodes) { + EventNode eventNode = (EventNode)ce; // SrcSnk nodes not yet added! if (matches(eventNode, nonElasticGroupFilter)) { String pid = eventNode.getEvent().getAttributeValue(nonElasticGroupPartitioning); if (pid != null) { // skip claim events without partitioning attribute @@ -185,7 +189,7 @@ public class ConstraintGraph { private static boolean matches(EventNode ce, Map filter) { if (filter != null && filter.size() > 0) { - for (Map.Entry entry : filter.entrySet()) { + for (Map.Entry entry: filter.entrySet()) { String val = ce.getEvent().getAttributeValue(entry.getKey()); if (!entry.getValue().equals(val)) { return false; @@ -197,7 +201,7 @@ public class ConstraintGraph { private void applyDependencies(List deps) { Map> succs = new HashMap<>(); - for (IDependency dep : deps) { + for (IDependency dep: deps) { IEvent src = dep.getSrc(); IEvent dst = dep.getDst(); Set s = succs.get(src); @@ -208,20 +212,20 @@ public class ConstraintGraph { s.add(dst); } Map eventMap = new HashMap<>(); - for (ConstraintGraphNode node : nodes) { + for (ConstraintGraphNode node: nodes) { if (node instanceof EventNode) { - EventNode en = (EventNode) node; + EventNode en = (EventNode)node; IEvent event = en.getEvent(); eventMap.put(event, en); } } - for (ConstraintGraphNode node : nodes) { + for (ConstraintGraphNode node: nodes) { if (node instanceof EventNode) { - EventNode en = (EventNode) node; + EventNode en = (EventNode)node; IEvent src = en.getEvent(); Set ss = succs.get(src); if (ss != null) { - for (IEvent s : ss) { + for (IEvent s: ss) { EventNode dst = eventMap.get(s); en.addConstraint(dst, 0); } @@ -231,52 +235,49 @@ public class ConstraintGraph { } /** - * Adds constraints between end event {@code e1} and start event {@code e2} with weight {@code 0} if and - * only if {@code e1.timestamp <= e2.timestamp() <= e1.timestamp + epsilon}. Furthermore, the transitive - * reduction of the implied constraints is taken. - * - * @param epsilon + * Adds constraints between end event {@code e1} and start event {@code e2} with weight {@code 0} if and only if + * {@code e1.timestamp <= e2.timestamp() <= e1.timestamp + epsilon}. Furthermore, the transitive reduction of the + * implied constraints is taken. */ private void applyOrderHeuristic(double epsilon) { if (epsilon < 0) { throw new IllegalArgumentException("epsilon must be at least 0"); } // only end events of the front of finished tasks - List F = new ArrayList(); - for (ConstraintGraphNode v : nodes) { + List f = new ArrayList(); + for (ConstraintGraphNode v: nodes) { if (v instanceof ClaimNode) { - ClaimNode claimNode = (ClaimNode) v; + ClaimNode claimNode = (ClaimNode)v; if (claimNode.isClaimStart()) { - for (ClaimNode w : F) { - if (epsilon == Double.POSITIVE_INFINITY - || (v.timestamp() - w.timestamp() <= epsilon)) { + for (ClaimNode w: f) { + if (epsilon == Double.POSITIVE_INFINITY || (v.timestamp() - w.timestamp() <= epsilon)) { w.addConstraint(v, 0); } } } else if (claimNode.isClaimStop()) { Set toRemove = new HashSet(); - for (ClaimNode w : F) { + for (ClaimNode w: f) { // w is an end event, and so is v. Check whether w goes to the start event of v - for (Constraint succw : w.constraints()) { + for (Constraint succw: w.constraints()) { ConstraintGraphNode s = succw.getDst(); if (s instanceof ClaimNode) { - if (((ClaimNode) s).isClaimStart() - && ((ClaimNode) s).getClaim() == claimNode.getClaim()) { + if (((ClaimNode)s).isClaimStart() + && ((ClaimNode)s).getClaim() == claimNode.getClaim()) + { toRemove.add(w); } } } // removed end events from F that can never lead to a constraint anymore // because the nodes are sorted by timestamp - if (epsilon != Double.POSITIVE_INFINITY - && (v.timestamp() - w.timestamp() > epsilon)) { + if (epsilon != Double.POSITIVE_INFINITY && (v.timestamp() - w.timestamp() > epsilon)) { toRemove.add(w); } } - for (ConstraintGraphNode k : toRemove) { - F.remove(k); + for (ConstraintGraphNode k: toRemove) { + f.remove(k); } - F.add(claimNode); + f.add(claimNode); } } } @@ -285,10 +286,10 @@ public class ConstraintGraph { private void addSourceAndSink() { ConstraintGraphNode src = new SrcSnkNode(0, true); ConstraintGraphNode snk = new SrcSnkNode(nodes.size() + 1, false); - for (ConstraintGraphNode e : nodes) { + for (ConstraintGraphNode e: nodes) { e.addConstraint(snk, 0); } - for (ConstraintGraphNode e : nodes) { + for (ConstraintGraphNode e: nodes) { src.addConstraint(e, 0); } // Add src and snk @@ -296,33 +297,12 @@ public class ConstraintGraph { nodes.add(snk); } - private Set getNodesWithPositiveIncomingEdges() { - Set withPositiveIncomingEdges = new HashSet<>(); - for (ConstraintGraphNode e : nodes) { - for (Constraint c : e.constraints()) { - if (c.weight() >= 0) { - withPositiveIncomingEdges.add(c.getDst()); - } - } - } - return withPositiveIncomingEdges; - } - - private boolean hasPositiveOutgoingEdge(ConstraintGraphNode e) { - for (Constraint c : e.constraints()) { - if (c.weight() >= 0) { - return true; - } - } - return false; - } - @Override public final String toString() { StringBuilder b = new StringBuilder("ConstraintGraph[size="); b.append(nodes.size()).append("]:\n"); - for (ConstraintGraphNode e : nodes) { - for (Constraint edge : e.constraints()) { + for (ConstraintGraphNode e: nodes) { + for (Constraint edge: e.constraints()) { if (!edge.isClaimDurationConstraint()) { b.append("\t\t").append(edge).append("\n"); } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/constraintgraph/impl/ConstraintGraphNode.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/constraintgraph/impl/ConstraintGraphNode.java index 1248a556f3ee61924eb6e433265b0cc98809c906..66ced3aa485931e7d18714e154e83cb71ed03378 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/constraintgraph/impl/ConstraintGraphNode.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/constraintgraph/impl/ConstraintGraphNode.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.constraintgraph.impl; import java.util.ArrayList; @@ -18,7 +19,6 @@ import org.eclipse.trace4cps.core.IEvent; * Implementation that wraps {@link IEvent} instances. */ public abstract class ConstraintGraphNode implements Comparable { - private final List succ = new ArrayList(); // id starts at 0 @@ -29,14 +29,11 @@ public abstract class ConstraintGraphNode implements Comparable + * ClaimEvents belong to a {@link ConstraintGraph} {@code cg}. The ids range from 0 to {@code cg.size()-1}, and + * every ClaimEvent has an unique id within the ConstraintGraph. The ids can thus be used to index an array. + *

    * If the constraint graph has source and sink nodes, then the source has id 0, and the sink has id * {@code cg.size() - 1}. - * - * @return */ public int getId() { return id; @@ -58,7 +55,7 @@ public abstract class ConstraintGraphNode implements Comparable criticalDeps; public CpaResult(List criticalDeps) { @@ -29,7 +29,7 @@ public final class CpaResult { public List getCriticalDeps() { return criticalDeps; } - + public static boolean isNonAppDependency(IDependency dep, DependencyProvider p) { if (p == null || p.isApplicationDependency(dep.getSrc(), dep.getDst())) { return false; @@ -37,8 +37,8 @@ public final class CpaResult { // p != null && !p.isApplicationDependency // also ensure that this is not an intra-claim dependency if (dep.getSrc() instanceof IClaimEvent && dep.getDst() instanceof IClaimEvent) { - IClaim src = ((IClaimEvent) dep.getSrc()).getClaim(); - IClaim dst = ((IClaimEvent) dep.getDst()).getClaim(); + IClaim src = ((IClaimEvent)dep.getSrc()).getClaim(); + IClaim dst = ((IClaimEvent)dep.getDst()).getClaim(); if (src == dst) { return false; } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/cpa/CriticalPathAnalysis.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/cpa/CriticalPathAnalysis.java index df51665c3544dc3d372d27bec8dbed73e3832836..41a86d5d77b664dc4de4fa68b2a635d6aff76843 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/cpa/CriticalPathAnalysis.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/cpa/CriticalPathAnalysis.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.cpa; import java.util.ArrayList; @@ -28,18 +29,17 @@ import org.eclipse.trace4cps.core.ITrace; import org.eclipse.trace4cps.core.impl.Dependency; /** - * This class implements critical-path analysis based on the constraint graph representation of the - * {@link IEvent} instances of an {@link ITrace}. References: + * This class implements critical-path analysis based on the constraint graph representation of the {@link IEvent} + * instances of an {@link ITrace}. References: *
      *
    • M. Hendriks and F. W. Vaandrager. Reconstructing critical paths from execution traces. In International * Conference on Embedded and Ubiquitous Computing (EUC 2012). IEEE Computer Society Press, 2012.
    • - *
    • M. Hendriks, J. Verriet, T. Basten, B. Theelen, M. Brasse, L. Somers. Analyzing Execution Traces - - * Critical-Path Analysis and Distance Analysis. International Journal on Software Tools for Technology - * Transfer, STTT. 19(4):487-510, August 2017.
    • + *
    • M. Hendriks, J. Verriet, T. Basten, B. Theelen, M. Brasse, L. Somers. Analyzing Execution Traces - Critical-Path + * Analysis and Distance Analysis. International Journal on Software Tools for Technology Transfer, STTT. 19(4):487-510, + * August 2017.
    • *
    */ public final class CriticalPathAnalysis { - public static final String CPA_ATT_TYPE = "type"; public static final String CPA_ATT_TYPE_CG = "cg"; @@ -55,7 +55,6 @@ public final class CriticalPathAnalysis { public static IAttributeFilter getCriticalDependencyFilter() { return new IAttributeFilter() { - @Override public boolean include(IAttributeAware a) { return CPA_ATT_CRITICAL_TRUE.equals(a.getAttributeValue(CPA_ATT_CRITICAL)); @@ -65,11 +64,11 @@ public final class CriticalPathAnalysis { /** * Default configuration for constraint graph: ordering heuristic with {@code epsilon = 0}. - * + * * @param trace the {@link ITrace} whose events to analyze for a critical-path * @return the result - * @throws PositiveCycleException if there are cyclic dependencies that make that critical-path analysis - * is not possible + * @throws PositiveCycleException if there are cyclic dependencies that make that critical-path analysis is not + * possible */ public static CpaResult run(ITrace trace) throws PositiveCycleException { ConstraintConfig config = ConstraintConfig.getDefault(); @@ -80,12 +79,12 @@ public final class CriticalPathAnalysis { /** * Manual configuration for the constraint graph of the critical-path analysis. - * + * * @param trace the {@link ITrace} whose events to analyze for a critical-path * @param config the manual configuration for the analysis * @return the result - * @throws PositiveCycleException if there are cyclic dependencies that make that critical-path analysis - * is not possible + * @throws PositiveCycleException if there are cyclic dependencies that make that critical-path analysis is not + * possible */ public static CpaResult run(ITrace trace, ConstraintConfig config) throws PositiveCycleException { if (!config.isAddSourceAndSink()) { @@ -94,16 +93,16 @@ public final class CriticalPathAnalysis { return applyBellmanFord(trace, config); } - private static CpaResult applyBellmanFord(ITrace trace, ConstraintConfig config) - throws PositiveCycleException { + private static CpaResult applyBellmanFord(ITrace trace, ConstraintConfig config) throws PositiveCycleException { if (config.isUseDependencies() && config.isApplyOrderingHeuristic()) { throw new IllegalArgumentException("cannot use dependencies and ordering heuristic"); } ConstraintGraph cg = new ConstraintGraph(trace, config); ConstraintGraphNode cgSrc = cg.getNodes().get(0); ConstraintGraphNode cgSnk = cg.getNodes().get(cg.getNodes().size() - 1); - double dist[] = new double[cg.size()]; - Set pre[] = new HashSet[cg.size()]; // FIXME: list of constraints + double[] dist = new double[cg.size()]; + @SuppressWarnings("unchecked") + Set[] pre = new HashSet[cg.size()]; // FIXME: list of constraints initializeBFdata(cg, dist, pre, cgSrc); // relax edges at most |V| times for (int i = 0; i < cg.size(); i++) { @@ -111,7 +110,7 @@ public final class CriticalPathAnalysis { boolean change = false; for (int j = 0; j < cg.size(); j++) { ConstraintGraphNode src = cg.getNodes().get(j); - for (Constraint edge : src.constraints()) { + for (Constraint edge: src.constraints()) { ConstraintGraphNode dst = edge.getDst(); if (dist[src.getId()] + edge.weight() > dist[dst.getId()]) { dist[dst.getId()] = dist[src.getId()] + edge.weight(); @@ -134,7 +133,8 @@ public final class CriticalPathAnalysis { } private static void initializeBFdata(ConstraintGraph cg, double[] dist, Set[] pre, - ConstraintGraphNode startNode) { + ConstraintGraphNode startNode) + { for (int i = 0; i < cg.size(); i++) { pre[i] = new HashSet(); } @@ -144,10 +144,9 @@ public final class CriticalPathAnalysis { dist[startNode.getId()] = 0; } - private static void assertNoPositiveCycles(ConstraintGraph cg, double[] dist) - throws PositiveCycleException { - for (ConstraintGraphNode ei : cg.getNodes()) { - for (Constraint edge : ei.constraints()) { + private static void assertNoPositiveCycles(ConstraintGraph cg, double[] dist) throws PositiveCycleException { + for (ConstraintGraphNode ei: cg.getNodes()) { + for (Constraint edge: ei.constraints()) { if (dist[ei.getId()] + edge.weight() > dist[edge.getDst().getId()]) { throw new PositiveCycleException("graph contains a positive-weight cycle: " + ei); } @@ -156,21 +155,22 @@ public final class CriticalPathAnalysis { } private static CpaResult computeResult(ConstraintGraphNode srcNode, ConstraintGraphNode snkNode, - Collection[] pre, ConstraintGraph cg) { + Collection[] pre, ConstraintGraph cg) + { List criticalDeps = new ArrayList<>(); List waiting = new ArrayList<>(); waiting.add(cg.getNodes().get(cg.size() - 1)); // add the sink Set passed = new HashSet<>(); while (!waiting.isEmpty()) { ConstraintGraphNode dst = waiting.remove(waiting.size() - 1); - for (Constraint constraint : pre[dst.getId()]) { + for (Constraint constraint: pre[dst.getId()]) { ConstraintGraphNode src = constraint.getSrc(); if (!passed.contains(src)) { waiting.add(src); } if (src instanceof EventNode && dst instanceof EventNode) { - IEvent srcEvent = ((EventNode) src).getEvent(); - IEvent dstEvent = ((EventNode) dst).getEvent(); + IEvent srcEvent = ((EventNode)src).getEvent(); + IEvent dstEvent = ((EventNode)dst).getEvent(); IDependency dep = new Dependency(srcEvent, dstEvent); dep.setAttribute(CPA_ATT_CRITICAL, CPA_ATT_CRITICAL_TRUE); criticalDeps.add(dep); diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/cpa/DependencyProvider.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/cpa/DependencyProvider.java index 7455b55142aba14908563fe869e18c799d4bf5fd..5ba2f6a523fa063c75d9b959ea59028dc687bfbd 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/cpa/DependencyProvider.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/cpa/DependencyProvider.java @@ -7,19 +7,19 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.cpa; import org.eclipse.trace4cps.core.IEvent; /** - * This type can be used to refine the critical-path analysis by adding information on the logical - * dependencies between claims that are due to the application. + * This type can be used to refine the critical-path analysis by adding information on the logical dependencies between + * claims that are due to the application. */ public interface DependencyProvider { - /** * Indicates whether a dependency between two events is a logical/data/application dependency. - * + * * @param src the source event * @param dst the destination event * @return whether a dependency from src to dst is due to the application diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/cpa/PositiveCycleException.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/cpa/PositiveCycleException.java index 24ff157db3d548b342037bfbb71cb8813e682e63..73223aa50612e5aea3b1cd60c01a448f15bbb012 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/cpa/PositiveCycleException.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/cpa/PositiveCycleException.java @@ -7,12 +7,12 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.cpa; import org.eclipse.trace4cps.analysis.AnalysisException; public class PositiveCycleException extends AnalysisException { - private static final long serialVersionUID = 1L; public PositiveCycleException() { diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/dist/DefaultRepresentation.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/dist/DefaultRepresentation.java index da6e9ee00c1a3c2d9156357ec63a9b4a5e5d1503..bf4b4d17edf309c8c5a391123b83b0e319be0f94 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/dist/DefaultRepresentation.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/dist/DefaultRepresentation.java @@ -7,19 +7,19 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.dist; import org.eclipse.trace4cps.core.IEvent; import org.eclipse.trace4cps.core.impl.TraceHelper; /** - * Default implementation of the {@link Representation} interface. An {@link IEvent} is represented by a - * string with the keys and values of its attributes (in lexicographical order w.r.t. the keys). Furthermore, - * {@link IClaimEvent} instances also have the keys and values of the resource attributes, the amount and - * offset that is claimed, and the type of {@link IClaimEvent}. + * Default implementation of the {@link Representation} interface. An {@link IEvent} is represented by a string with the + * keys and values of its attributes (in lexicographical order w.r.t. the keys). Furthermore, {@link IClaimEvent} + * instances also have the keys and values of the resource attributes, the amount and offset that is claimed, and the + * type of {@link IClaimEvent}. */ public class DefaultRepresentation implements Representation { - /** * {@inheritDoc} */ diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/dist/DependencyInclusionCheck.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/dist/DependencyInclusionCheck.java index 52ad0c51de92a4ec58f7f50f7bf8cda7bc72a761..b68396493e819861924a8fb6909fa40cf727aa13 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/dist/DependencyInclusionCheck.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/dist/DependencyInclusionCheck.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.dist; import java.util.ArrayList; @@ -22,28 +23,24 @@ import org.eclipse.trace4cps.core.impl.Dependency; /** *

    - * This type provides a check on two traces. One trace typically comes from a model (e.g., an LSAT model) and - * contains dependencies between claims and/or events. The other trace typically is from a system. The - * assumption is that a mapping exists between the claims and events in the two traces. This mapping is the - * equality of attribute-values. E.g., a claim in the model trace is equivalent to a claim in the system trace - * if and only if they have exactly the same set of attributes and values. Furthermore, we assume that a - * dependency in the model trace encodes a timing/ordering dependency: the destination of the dependency does - * not happen before the source of the dependency. We can also quantify the minimal time distance by a special - * attribute of the dependency that is interpreted as a time duration in the time unit of the traces (which - * must be equal). The algorithm in this class then checks whether every dependency in the model trace is - * respected in the system trace. + * This type provides a check on two traces. One trace typically comes from a model (e.g., an LSAT model) and contains + * dependencies between claims and/or events. The other trace typically is from a system. The assumption is that a + * mapping exists between the claims and events in the two traces. This mapping is the equality of attribute-values. + * E.g., a claim in the model trace is equivalent to a claim in the system trace if and only if they have exactly the + * same set of attributes and values. Furthermore, we assume that a dependency in the model trace encodes a + * timing/ordering dependency: the destination of the dependency does not happen before the source of the dependency. We + * can also quantify the minimal time distance by a special attribute of the dependency that is interpreted as a time + * duration in the time unit of the traces (which must be equal). The algorithm in this class then checks whether every + * dependency in the model trace is respected in the system trace. *

    */ public class DependencyInclusionCheck { - private DependencyInclusionCheck() { } /** - * @param modelTrace - * @param systemTrace - * @param weightAttribute the attribute to interpret as the minimum time distance for the dependencies - * (can be {@code null} in which case a value of 0 is used) + * @param weightAttribute the attribute to interpret as the minimum time distance for the dependencies (can be + * {@code null} in which case a value of 0 is used) * @return constraints from the model trace which are not satisfied by the system trace */ public static List check(ITrace modelTrace, ITrace systemTrace, String weightAttribute) { @@ -53,8 +50,7 @@ public class DependencyInclusionCheck { List systemDependencies = new ArrayList<>(); Map cache = new HashMap<>(); - int cnt = 0; - for (IDependency d : modelTrace.getDependencies()) { + for (IDependency d: modelTrace.getDependencies()) { IEvent e1 = get(cache, d.getSrc(), systemTrace); IEvent e2 = get(cache, d.getDst(), systemTrace); if (e1 != null && e2 != null) { @@ -63,7 +59,6 @@ public class DependencyInclusionCheck { IDependency annotatedDep = new Dependency(e1, e2); annotatedDep.setAttribute(weightAttribute, Double.toString(weight)); systemDependencies.add(annotatedDep); - cnt++; } } } @@ -86,9 +81,9 @@ public class DependencyInclusionCheck { } /** - * Gets a system event from the system trace that is the equivalent of the given model event. Already - * computed pairs are stored in the cache. - * + * Gets a system event from the system trace that is the equivalent of the given model event. Already computed pairs + * are stored in the cache. + * * @param cache the cache of model-system event pairs * @param modelEvent the model event for which to find the equivalent system event * @param systemTrace the trace with all system events @@ -99,9 +94,8 @@ public class DependencyInclusionCheck { if (r != null) { return r; } - for (IEvent sysEvent : systemTrace.getEvents()) { - if (eventTypeEquals(modelEvent, sysEvent) - && modelEvent.getAttributes().equals(sysEvent.getAttributes())) { + for (IEvent sysEvent: systemTrace.getEvents()) { + if (eventTypeEquals(modelEvent, sysEvent) && modelEvent.getAttributes().equals(sysEvent.getAttributes())) { cache.put(modelEvent, sysEvent); return sysEvent; } @@ -115,7 +109,7 @@ public class DependencyInclusionCheck { } else if (!(lsatEvent instanceof IClaimEvent) && sysEvent instanceof IClaimEvent) { return false; } else if (lsatEvent instanceof IClaimEvent && sysEvent instanceof IClaimEvent) { - if (((IClaimEvent) lsatEvent).getType() != ((IClaimEvent) sysEvent).getType()) { + if (((IClaimEvent)lsatEvent).getType() != ((IClaimEvent)sysEvent).getType()) { return false; } } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/dist/DistanceAnalysis.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/dist/DistanceAnalysis.java index 1589385b78ef60ae7b8b276dd20b85ec32b0a4a4..4fd3a7ff523f5b625ebd39db2fdd01037ec34af9 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/dist/DistanceAnalysis.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/dist/DistanceAnalysis.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.dist; import java.util.ArrayList; @@ -28,24 +29,23 @@ import org.eclipse.trace4cps.core.ITrace; /** * This class provides methods to compute a distance between sets of {@link IEvent} instances. References: *
      - *
    • M. Hendriks, J. Verriet, T. Basten, B. Theelen, M. Brasse, L. Somers. Analyzing Execution Traces - - * Critical-Path Analysis and Distance Analysis. International Journal on Software Tools for Technology - * Transfer, STTT. 19(4):487-510, August 2017.
    • + *
    • M. Hendriks, J. Verriet, T. Basten, B. Theelen, M. Brasse, L. Somers. Analyzing Execution Traces - Critical-Path + * Analysis and Distance Analysis. International Journal on Software Tools for Technology Transfer, STTT. 19(4):487-510, + * August 2017.
    • *
    *

    - * The algorithm needs a {@link Representation} implementation to represents {@link IEvent} instances as - * strings. This is used by the algorithm to determine equality of events of the different given event sets. - * It is essential that within each event within a list of events has a unique string representation. + * The algorithm needs a {@link Representation} implementation to represents {@link IEvent} instances as strings. This + * is used by the algorithm to determine equality of events of the different given event sets. It is essential that + * within each event within a list of events has a unique string representation. *

    */ public final class DistanceAnalysis { - private DistanceAnalysis() { } /** * Computes the distance between two lists of events as a natural number ({@code >= 0}). - * + * * @param e1 the first list of events * @param e2 the second list of events * @param r the representation used for equality computation @@ -81,19 +81,17 @@ public final class DistanceAnalysis { } /** - * Computes the distance between two lists of events as a natural number ({@code >=0}). It also annotates - * the reference list of events through the {@link DistanceResult#getInterestCount()} interest count - * map. - * + * Computes the distance between two lists of events as a natural number ({@code >=0}). It also annotates the + * reference list of events through the {@link DistanceResult#getInterestCount()} interest count map. + * * @param e1 a list of events (the "reference") * @param e2 a list of events * @param r a representation function for the events * @param annotateReference whether the reference trace will be included in the annotation of - * {@link DistanceResult#getInterestCount()} + * {@link DistanceResult#getInterestCount()} * @return a {@link DistanceResult} */ - public static DistanceResult distance(ITrace e1, ITrace e2, Representation r, - boolean annotateReference) { + public static DistanceResult distance(ITrace e1, ITrace e2, Representation r, boolean annotateReference) { ConstraintConfig cfg = ConstraintConfig.getDefault(); cfg.setApplyOrderingHeuristic(Double.POSITIVE_INFINITY); ConstraintGraph g1 = new ConstraintGraph(e1, cfg); @@ -102,7 +100,8 @@ public final class DistanceAnalysis { } private static DistanceResult run(ConstraintGraph g1, ConstraintGraph g2, Representation r, - boolean annotateReference) { + boolean annotateReference) + { long distance = 0; Map interestCount = new HashMap<>(); @@ -113,11 +112,11 @@ public final class DistanceAnalysis { Set v2minv1 = computeSetMinus(v2.values(), v1.values()); distance += (v1minv2.size() + v2minv1.size()); if (annotateReference) { - for (VertexClaimWrapper v : v1minv2) { + for (VertexClaimWrapper v: v1minv2) { interestCount.put(v.node.getEvent(), new InterestWrapper(v.node.getEvent())); } } - for (VertexClaimWrapper v : v2minv1) { + for (VertexClaimWrapper v: v2minv1) { interestCount.put(v.node.getEvent(), new InterestWrapper(v.node.getEvent())); } @@ -132,7 +131,7 @@ public final class DistanceAnalysis { // Convert: Map> ic = new HashMap<>(); - for (InterestWrapper w : interestCount.values()) { + for (InterestWrapper w: interestCount.values()) { List list = ic.get(w.cnt); if (list == null) { list = new ArrayList<>(); @@ -145,8 +144,9 @@ public final class DistanceAnalysis { } private static void annotateEdges(Map interestCount, boolean annotateV1, - boolean annotateV2, Set e1mine2, Map v2) { - for (EdgeClaimWrapper e : e1mine2) { + boolean annotateV2, Set e1mine2, Map v2) + { + for (EdgeClaimWrapper e: e1mine2) { // e.src and e.dst are in V1, the reference trace: if (annotateV1) { increment(e.getSrc(), interestCount); @@ -178,13 +178,13 @@ public final class DistanceAnalysis { private static Map getVertices(ConstraintGraph g, Representation repr) { Map r = new HashMap(); int dup = 1; - for (ConstraintGraphNode n : g.getNodes()) { - VertexClaimWrapper w = new VertexClaimWrapper((EventNode) n, repr); + for (ConstraintGraphNode n: g.getNodes()) { + VertexClaimWrapper w = new VertexClaimWrapper((EventNode)n, repr); if (r.containsKey(w.representation)) { // we have a claims/vertices with identical attributes (e.g., due to // preemption,...) // add a duplication counter: the nodes in CG are ordered according to timestamp - w = new VertexClaimWrapper((EventNode) n, repr, dup); + w = new VertexClaimWrapper((EventNode)n, repr, dup); dup++; } r.put(w.representation, w); @@ -194,16 +194,16 @@ public final class DistanceAnalysis { private static Set getVerticesAsSet(ConstraintGraph g, Representation repr) { Set r = new HashSet(); - for (ConstraintGraphNode n : g.getNodes()) { - r.add(new VertexClaimWrapper((EventNode) n, repr)); + for (ConstraintGraphNode n: g.getNodes()) { + r.add(new VertexClaimWrapper((EventNode)n, repr)); } return r; } private static Set getEdges(ConstraintGraph g, Representation repr) { Set r = new HashSet(); - for (ConstraintGraphNode e : g.getNodes()) { - for (Constraint c : e.constraints()) { + for (ConstraintGraphNode e: g.getNodes()) { + for (Constraint c: e.constraints()) { r.add(new EdgeClaimWrapper(c, repr)); } } @@ -212,12 +212,12 @@ public final class DistanceAnalysis { private static Set computeSymDif(Set s1, Set s2) { Set result = new HashSet(); - for (T o1 : s1) { + for (T o1: s1) { if (!s2.contains(o1)) { result.add(o1); } } - for (T o2 : s2) { + for (T o2: s2) { if (!s1.contains(o2)) { result.add(o2); } @@ -226,13 +226,11 @@ public final class DistanceAnalysis { } /** - * @param s1 - * @param s2 * @return s1 \ s2 */ private static Set computeSetMinus(Collection s1, Collection s2) { Set result = new HashSet(); - for (T o1 : s1) { + for (T o1: s1) { if (!s2.contains(o1)) { result.add(o1); } @@ -241,7 +239,6 @@ public final class DistanceAnalysis { } private static final class VertexClaimWrapper { - private final String representation; private final EventNode node; @@ -272,7 +269,7 @@ public final class DistanceAnalysis { if (getClass() != obj.getClass()) { return false; } - VertexClaimWrapper other = (VertexClaimWrapper) obj; + VertexClaimWrapper other = (VertexClaimWrapper)obj; if (representation == null) { if (other.representation != null) { return false; @@ -290,11 +287,8 @@ public final class DistanceAnalysis { } private static final class EdgeClaimWrapper { - private final String representation; - private final Constraint c; - private final EventNode src; private final EventNode dst; @@ -304,9 +298,8 @@ public final class DistanceAnalysis { private final String dstRep; private EdgeClaimWrapper(Constraint c, Representation r) { - this.c = c; - this.src = (EventNode) c.getSrc(); - this.dst = (EventNode) c.getDst(); + this.src = (EventNode)c.getSrc(); + this.dst = (EventNode)c.getDst(); this.srcRep = r.represent(src.getEvent()); this.dstRep = r.represent(dst.getEvent()); StringBuilder b = new StringBuilder(); @@ -338,7 +331,7 @@ public final class DistanceAnalysis { if (getClass() != obj.getClass()) { return false; } - EdgeClaimWrapper other = (EdgeClaimWrapper) obj; + EdgeClaimWrapper other = (EdgeClaimWrapper)obj; if (representation == null) { if (other.representation != null) { return false; @@ -356,7 +349,6 @@ public final class DistanceAnalysis { } private static final class InterestWrapper { - private int cnt; private final IEvent event; diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/dist/DistanceResult.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/dist/DistanceResult.java index 376a92cb761fcb5af7f1c4fb76811f85f9cf774c..8919d7877be2c28eac28b6f4f4b3c4395cf4f1db 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/dist/DistanceResult.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/dist/DistanceResult.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.dist; import java.util.List; @@ -18,7 +19,6 @@ import org.eclipse.trace4cps.core.IEvent; * The result of a {@link DistanceAnalysis} computation. */ public final class DistanceResult { - private final long distance; private final Map> interestCount; @@ -36,10 +36,10 @@ public final class DistanceResult { } /** - * This method returns a map that gives a heuristic interest number to a subset of events. The - * higher the interest number, the more the event is involved in the distance. This information can, e.g., - * be used for visualization purposes. - * + * This method returns a map that gives a heuristic interest number to a subset of events. The higher the + * interest number, the more the event is involved in the distance. This information can, e.g., be used for + * visualization purposes. + * * @return the interest map */ public Map> getInterestCount() { diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/dist/Representation.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/dist/Representation.java index ffaaeb668bfa80ba72bb3da877b2c2b810cffc47..e06e570f086b86a1786cf0ef4d85da978754aa67 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/dist/Representation.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/dist/Representation.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.dist; import org.eclipse.trace4cps.core.IEvent; @@ -15,10 +16,9 @@ import org.eclipse.trace4cps.core.IEvent; * Provides a string representation of an {@link IEvent} for the difference analysis. */ public interface Representation { - /** * @param e the {@link IEvent} to represent * @return the string representation of the event */ String represent(IEvent e); -} \ No newline at end of file +} diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/AtomicProposition.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/AtomicProposition.java index 9be7f27c5c3320f1b65ec8c696eee040c262ccc9..0f9ec3ec0a616c9a74eb1d1876f875d17fb34852 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/AtomicProposition.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/AtomicProposition.java @@ -7,31 +7,31 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl; import org.eclipse.trace4cps.core.ClaimEventType; import org.eclipse.trace4cps.core.IAttributeAware; +import org.eclipse.trace4cps.core.IClaimEvent; +import org.eclipse.trace4cps.core.IEvent; /** - * An atomic proposition is a core building block for {@link MtlFormula}. It is specified by the set of - * attributes and the (possibly null) {@link ClaimEventType}. The atomic proposition is designed to work - * together with the {@link IEvent} and {@link IClaimEvent} instances, which both extend the {@link State} - * interface. Implementations of the {@link State} have a {@link State#satisfies(AtomicProposition)} - * method that typically must the attributes and the type of the atomic proposition. I.e., a state {@code s} - * satisfies an atomic proposition {@code p} if and only if + * An atomic proposition is a core building block for {@link MtlFormula}. It is specified by the set of attributes and + * the (possibly null) {@link ClaimEventType}. The atomic proposition is designed to work together with the + * {@link IEvent} and {@link IClaimEvent} instances, which both extend the {@link State} interface. Implementations of + * the {@link State} have a {@link State#satisfies(AtomicProposition)} method that typically must the attributes and the + * type of the atomic proposition. I.e., a state {@code s} satisfies an atomic proposition {@code p} if and only if *
      - *
    • all attribute-value pairs of the atomic proposition {@code p} are also present in the state {@code s}, - * and
    • + *
    • all attribute-value pairs of the atomic proposition {@code p} are also present in the state {@code s}, and
    • *
    • {@code p.}{@link #getType()}{@code == null} or state {@code s} has the same type as * {@code p.}{@link #getType()}}
    • *
    - * + * */ public interface AtomicProposition extends MtlFormula, IAttributeAware { - /** * Maybe {@code null} to specify any event type - * + * * @return the type of this atomic proposition */ ClaimEventType getType(); diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/DefaultAtomicProposition.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/DefaultAtomicProposition.java index f38a684f0b8fb2ebd522564cc3380169da8942e6..bdf78a72c59abfe7436df5152e5ea0f3259efc1a 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/DefaultAtomicProposition.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/DefaultAtomicProposition.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl; import java.util.Collections; @@ -20,7 +21,6 @@ import org.eclipse.trace4cps.core.ClaimEventType; * A default implementation of an {@link AtomicProposition} based on a key-value mapping of strings. */ public class DefaultAtomicProposition extends AbstractMTLformula implements AtomicProposition { - private final Map properties = new HashMap<>(); private final ClaimEventType type; diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/ExplanationTable.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/ExplanationTable.java index fea63f1a7410ca24aea1070ff0838e730bd55fac..a99d6f040776a5ea6097ae5f96d3ea006de0770a 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/ExplanationTable.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/ExplanationTable.java @@ -7,16 +7,16 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl; import java.util.List; /** - * An explanation table gives for all subformulas of some {@link MtlFormula} the indices in the trace on which - * it has been checked and the truth value ({@link InformativePrefix}) on that index. + * An explanation table gives for all subformulas of some {@link MtlFormula} the indices in the trace on which it has + * been checked and the truth value ({@link InformativePrefix}) on that index. */ public interface ExplanationTable { - /** * @return the list of states to which this table belongs */ @@ -32,7 +32,6 @@ public interface ExplanationTable { * A region gives for parts of the trace (list of states) the computed satisfaction value. */ public interface Region { - /** * @return the start index of this region (inclusive) */ diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/InformativePrefix.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/InformativePrefix.java index fc565ccffa34a0322a56142cf7e61a545caf6ce8..1d50a49bff5040a7f6a60bee15e1fdf40ab24d72 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/InformativePrefix.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/InformativePrefix.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl; /** @@ -15,21 +16,21 @@ package org.eclipse.trace4cps.analysis.mtl; public enum InformativePrefix { /** - * The formula is satisfied. If the state sequence is interpreted as a prefix, then any extension of the - * state sequence will not invalidate the formula. + * The formula is satisfied. If the state sequence is interpreted as a prefix, then any extension of the state + * sequence will not invalidate the formula. */ GOOD, /** - * This value can only occur when the state sequence is interpreted as a prefix. The state sequence does - * not give evidence that the formula is not satisfied. An extension of the state sequence may or may not - * invalidate the formula. + * This value can only occur when the state sequence is interpreted as a prefix. The state sequence does not give + * evidence that the formula is not satisfied. An extension of the state sequence may or may not invalidate the + * formula. */ NON_INFORMATIVE, /** - * The state sequence contains a counter example for the formula. If the state sequence is interpreted as - * a prefix, then any extension of the state sequence will not satisfy the formula. + * The state sequence contains a counter example for the formula. If the state sequence is interpreted as a prefix, + * then any extension of the state sequence will not satisfy the formula. */ BAD, diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlBuilder.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlBuilder.java index 0ccd22059fa5edeafede42680a82cdd42a34b418..57b8c0c57023e6c080eab056b8947536693844ab 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlBuilder.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlBuilder.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl; import org.eclipse.trace4cps.analysis.mtl.impl.MTLand; @@ -21,19 +22,18 @@ import org.eclipse.trace4cps.core.impl.Interval; * A utility class for building {@link MtlFormula} instances. */ public final class MtlBuilder { - - private static final MTLtrue mtlTrue = new MTLtrue(); + private static final MTLtrue MTL_TRUE = new MTLtrue(); private MtlBuilder() { } public static MtlFormula TRUE() { - return mtlTrue; + return MTL_TRUE; } public static MtlFormula NOT(MtlFormula f) { if (f instanceof MTLnot) { - return ((MTLnot) f).getChild(); + return ((MTLnot)f).getChild(); } else { return new MTLnot(f); } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlChecker.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlChecker.java index 948849b12b421a168a6160c73e4f23fbe7aa04c4..c2a95016132e64488ab00657e6f30123d4ecb21f 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlChecker.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlChecker.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl; import java.util.Collection; @@ -24,23 +25,23 @@ import org.eclipse.trace4cps.core.ITrace; /** * This class is the main entry point for runtime verification of STL-mx specifications on traces. Use the - * {@link MtlBuilder} class for construction of {@link MtlFormula} instances. The list of states typically is - * provided by {@link ITrace#getEvents()}}. - * + * {@link MtlBuilder} class for construction of {@link MtlFormula} instances. The list of states typically is provided + * by {@link ITrace#getEvents()}}. + *

    * References: *

    + *

    */ public final class MtlChecker { - private final int numThreads; /** @@ -52,7 +53,7 @@ public final class MtlChecker { /** * A checker that uses at most a given number of threads. - * + * * @param numThreads maximum number of threads to use */ public MtlChecker(int numThreads) { @@ -63,7 +64,7 @@ public final class MtlChecker { * Synchronously checks an STL-mx formula (i.e., an {@link MtlFormula} which may have {@link StlFormula} * subformulas). The trace is interpreted as a prefix if and only if the given formula does not contain * {@link StlFormula} parts. - * + * * @param trace the execution trace * @param phi the formula to check * @return the result @@ -75,10 +76,10 @@ public final class MtlChecker { /** * Synchronously checks an STL-mx formula (i.e., an {@link MtlFormula} which may have {@link StlFormula} - * subformulas). The result will contain an explanation of the formulas whose satisfaction value is - * contained in the given {@code explain} set. The trace can be interpreted as a prefix if and only if the - * given formula does not contain {@link StlFormula} parts. - * + * subformulas). The result will contain an explanation of the formulas whose satisfaction value is contained in the + * given {@code explain} set. The trace can be interpreted as a prefix if and only if the given formula does not + * contain {@link StlFormula} parts. + * * @param trace the execution trace * @param phi the formula to check * @param explain the set of truth values for which to generate an explanation (typically only BAD) @@ -86,10 +87,10 @@ public final class MtlChecker { * @return the result */ public MtlResult check(List trace, MtlFormula phi, Set explain, - boolean interpretAsPrefix) { + boolean interpretAsPrefix) + { if (interpretAsPrefix && !MtlUtil.isMtl(phi)) { - throw new IllegalArgumentException( - "trace can only be interpreted as a prefix for pure MTL formulas"); + throw new IllegalArgumentException("trace can only be interpreted as a prefix for pure MTL formulas"); } SingleFormulaChecker c = new RecursiveMemoizationChecker(); InformativePrefix r = c.check(trace, phi, explain, interpretAsPrefix); @@ -97,10 +98,10 @@ public final class MtlChecker { } /** - * A-synchronously checks a list of STL-mx formula (i.e., an {@link MtlFormula} which may have - * {@link StlFormula} subformulas). The trace is interpreted as a prefix if the given formula does not - * contain {@link StlFormula} parts. - * + * A-synchronously checks a list of STL-mx formula (i.e., an {@link MtlFormula} which may have {@link StlFormula} + * subformulas). The trace is interpreted as a prefix if the given formula does not contain {@link StlFormula} + * parts. + * * @param trace the execution trace * @param phis the formulas to check * @return the result @@ -110,24 +111,25 @@ public final class MtlChecker { } /** - * A-synchronously checks a list of STL-mx formula (i.e., an {@link MtlFormula} which may have - * {@link StlFormula} subformulas). The result will contain an explanation of the formulas whose - * satisfaction value is contained in the given {@code explain} set.The trace is interpreted as a prefix - * if the given formula does not contain {@link StlFormula} parts and {@code interpretAsPrefix = true}. - * + * A-synchronously checks a list of STL-mx formula (i.e., an {@link MtlFormula} which may have {@link StlFormula} + * subformulas). The result will contain an explanation of the formulas whose satisfaction value is contained in the + * given {@code explain} set.The trace is interpreted as a prefix if the given formula does not contain + * {@link StlFormula} parts and {@code interpretAsPrefix = true}. + * * @param trace the execution trace * @param phis the formulas to check * @param explain the set of truth values for which to generate an explanation (typically only BAD) - * @param tryInterpretAsPrefix whether to interpret the trace as a prefix (if true, then this is only - * applied if the formula is a pure MTL formula) + * @param tryInterpretAsPrefix whether to interpret the trace as a prefix (if true, then this is only applied if the + * formula is a pure MTL formula) * @return the result */ - public MtlFuture checkAll(List trace, Collection phis, - Set explain, boolean tryInterpretAsPrefix) { + public MtlFuture checkAll(List trace, Collection phis, Set explain, + boolean tryInterpretAsPrefix) + { List safeList = new CopyOnWriteArrayList(trace); ExecutorService exec = Executors.newFixedThreadPool(numThreads); MtlFuture future = new MtlFuture(phis.size(), exec); - for (MtlFormula phi : phis) { + for (MtlFormula phi: phis) { boolean pref = tryInterpretAsPrefix && MtlUtil.isMtl(phi); exec.submit(new CheckTask(safeList, phi, future, explain, pref)); } @@ -143,7 +145,6 @@ public final class MtlChecker { } private static final class CheckTask implements Runnable { - private final List trace; private final MtlFormula phi; @@ -155,7 +156,8 @@ public final class MtlChecker { private final boolean interpretAsPrefix; public CheckTask(List trace, MtlFormula phi, MtlFuture result, Set explain, - boolean interpretAsPrefix) { + boolean interpretAsPrefix) + { this.trace = trace; this.phi = phi; this.result = result; @@ -163,6 +165,7 @@ public final class MtlChecker { this.interpretAsPrefix = interpretAsPrefix; } + @Override public void run() { try { SingleFormulaChecker c = new RecursiveMemoizationChecker(); @@ -170,7 +173,7 @@ public final class MtlChecker { result.addToResult(phi, r, c.getExplanation()); } catch (Throwable th) { // th.printStackTrace(); - result.addError(th); + result.addError(th); } } } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlException.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlException.java index fc28b5bc6380c443d5af7b048ab4a5ac5c00f90a..c3d23328cb5ea6c6771b5b2ce82f51a527b2725e 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlException.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlException.java @@ -7,12 +7,12 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl; import org.eclipse.trace4cps.analysis.AnalysisException; public class MtlException extends AnalysisException { - private static final long serialVersionUID = 1L; public MtlException() { diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlFormula.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlFormula.java index 40cdd9b7710c06d95c9fc451352ee052128d5890..e07e954a8d9cd68886f459d0888f461302dbeaed 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlFormula.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlFormula.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl; import java.util.List; @@ -15,7 +16,6 @@ import java.util.List; * Top-level interface for metric-temporal logic formulas. */ public interface MtlFormula { - /** * @return sub formulas of this formula */ diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlFuture.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlFuture.java index e6d01549c8dfe0a4fbd4c583c2f1a4b96be4f533..ba19c6ddc494d96b524b42685a51a5587d5879a7 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlFuture.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlFuture.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl; import java.util.ArrayList; @@ -21,7 +22,6 @@ import java.util.concurrent.TimeoutException; * A future for an asynchronous temporal-logic verification. */ public final class MtlFuture implements Future> { - private final Object lock = new Object(); private final int total; @@ -161,7 +161,8 @@ public final class MtlFuture implements Future> { */ @Override public List get(long timeout, TimeUnit unit) - throws InterruptedException, ExecutionException, TimeoutException { + throws InterruptedException, ExecutionException, TimeoutException + { throw new UnsupportedOperationException(); } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlResult.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlResult.java index a3ad67edd0f5c86974d33786ee4ab51fec12d2e4..f2b4ed013605118c9d2c2a8d035ca991a0690077 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlResult.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlResult.java @@ -7,13 +7,13 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl; /** * The result of a computation of the {@link MtlChecker}. */ public final class MtlResult { - private final MtlFormula phi; private final InformativePrefix informativePrefix; @@ -42,9 +42,8 @@ public final class MtlResult { /** * An explanation is only available when it is explicitly asked to the {@link MtlChecker}. The - * {@link ExplanationTable} is a representation of the data structure that has been used to check the - * formula. - * + * {@link ExplanationTable} is a representation of the data structure that has been used to check the formula. + * * @return an explanation, or {@code null} if no explanation has been asked */ public ExplanationTable getExplanation() { diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlUtil.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlUtil.java index 11465ee342be098553ac2afbbfa7a912dfaa0232..3af3196b10fa849f15eb8264e403f388803c8697 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlUtil.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/MtlUtil.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl; import java.util.ArrayList; @@ -22,33 +23,32 @@ import org.eclipse.trace4cps.analysis.stl.StlFormula; * A utility class for handling MTL-related things. */ public final class MtlUtil { - private MtlUtil() { } public static boolean isMtl(MtlFormula phi) { - for (MtlFormula sub : getSubformulas(phi)) { + for (MtlFormula sub: getSubformulas(phi)) { if (sub instanceof StlFormula) { return false; } } return true; } - + public static boolean isStl(MtlFormula phi) { return phi instanceof StlFormula; } - + public static boolean isStlMx(MtlFormula phi) { - return !(isStl(phi) || isMtl(phi)); + return !(isStl(phi) || isMtl(phi)); } - + public static Collection getAtomicPropIndices(MtlResult r) { Set aps = getAtomicPropositions(r.getPhi()); ExplanationTable tab = r.getExplanation(); Set result = new HashSet(); - for (AtomicProposition ap : aps) { - for (Region region : tab.getRegions(ap)) { + for (AtomicProposition ap: aps) { + for (Region region: tab.getRegions(ap)) { if (region.getValue() == InformativePrefix.GOOD) { for (int i = region.getStartIndex(); i <= region.getEndIndex(); i++) { result.add(i); @@ -60,9 +60,8 @@ public final class MtlUtil { } /** - * * Returns all subformulas of a given formula in a depth-first order (including the formula itself). - * + * * @param phi the formula * @return a list of subformulas */ @@ -80,17 +79,17 @@ public final class MtlUtil { private static void depthFirstAP(MtlFormula phi, Set r) { if (!phi.getChildren().isEmpty()) { - for (MtlFormula c : phi.getChildren()) { + for (MtlFormula c: phi.getChildren()) { depthFirstAP(c, r); } } else if (phi instanceof AtomicProposition) { - r.add((AtomicProposition) phi); + r.add((AtomicProposition)phi); } } private static void depthFirstSub(MtlFormula phi, List r) { if (!phi.getChildren().isEmpty()) { - for (MtlFormula c : phi.getChildren()) { + for (MtlFormula c: phi.getChildren()) { depthFirstSub(c, r); } } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/State.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/State.java index c9962395d9b3dcda9596b4cab09472504c144955..b81f5af1e3d8f9f68843fb9555409f7d7f84a1a3 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/State.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/State.java @@ -7,20 +7,22 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl; import org.eclipse.trace4cps.core.IAttributeAware; +import org.eclipse.trace4cps.core.IEvent; /** - * Temporal-logic checking works on a sequence of {@link State} instances. Note that {@link IEvent} extends - * the {@link State} type. - * + * Temporal-logic checking works on a sequence of {@link State} instances. Note that {@link IEvent} extends the + * {@link State} type. + *

    * Each state has a timestamp, a number of attributes, and a method that gives the truth-value of a given - * {@link AtomicProposition}. Both {@link State} and {@link AtomicProposition} are {@link IAttributeAware}. - * The satisfaction relation uses the attributes, and also the {@link AtomicProposition#getType()} method. + * {@link AtomicProposition}. Both {@link State} and {@link AtomicProposition} are {@link IAttributeAware}. The + * satisfaction relation uses the attributes, and also the {@link AtomicProposition#getType()} method. + *

    */ public interface State extends IAttributeAware { - /** * @return the timestamp of this state */ diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/check/CompactExplanationTableImpl.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/check/CompactExplanationTableImpl.java index 8e565a046cfe8b7b020942ea4c9e624a5eaeae30..aa48f576346845e65ce11a7de0f3031791735ce9 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/check/CompactExplanationTableImpl.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/check/CompactExplanationTableImpl.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl.check; import java.util.ArrayList; @@ -22,7 +23,6 @@ import org.eclipse.trace4cps.analysis.mtl.impl.MTLtrue; * We need 4 bits per index,formula. Optimization for locality in Until computation: put all formulas together */ public final class CompactExplanationTableImpl implements TabularExplanationTable { - private final List trace; private final Map subForms; @@ -30,22 +30,22 @@ public final class CompactExplanationTableImpl implements TabularExplanationTabl private int trueIndex = -1; // Number of 32-bit ints to encode the truth values of 1 state - private final int P; + private final int p; private final int[] table; public CompactExplanationTableImpl(List trace, Map subForms) { this.trace = trace; this.subForms = subForms; - for (Map.Entry e : subForms.entrySet()) { + for (Map.Entry e: subForms.entrySet()) { if (e.getKey() instanceof MTLtrue) { trueIndex = e.getValue(); } } // We don't encode the true atom: - this.P = (subForms.size() / 8) + 1; - this.table = new int[P * trace.size()]; - for (int i = 0; i < P * trace.size(); i++) { + this.p = (subForms.size() / 8) + 1; + this.table = new int[p * trace.size()]; + for (int i = 0; i < p * trace.size(); i++) { table[i] = 0; } } @@ -62,12 +62,12 @@ public final class CompactExplanationTableImpl implements TabularExplanationTabl } // unpack value for formula: // return (table[stateIndex * P + formulaIndex / 8] >> (4 * (formulaIndex % 8))) & 15; - return (table[(stateIndex * P) + (formulaIndex >> 3)] >> ((formulaIndex & 7) << 2)) & 15; + return (table[(stateIndex * p) + (formulaIndex >> 3)] >> ((formulaIndex & 7) << 2)) & 15; } public int put(int formulaIndex, int stateIndex, int c) { // table[stateIndex * P + formulaIndex / 8] |= (c << (4 * (formulaIndex % 8))); - table[stateIndex * P + (formulaIndex >> 3)] |= (c << ((formulaIndex & 7) << 2)); + table[stateIndex * p + (formulaIndex >> 3)] |= (c << ((formulaIndex & 7) << 2)); return c; } @@ -103,16 +103,16 @@ public final class CompactExplanationTableImpl implements TabularExplanationTabl public InformativePrefix getValue(int formulaIndex, int index) { switch (get(formulaIndex, index)) { - case YES: - return InformativePrefix.GOOD; - case NO: - return InformativePrefix.BAD; - case MAYBE: - return InformativePrefix.NON_INFORMATIVE; - case UNKNOWN: - return InformativePrefix.NOT_COMPUTED; - default: - throw new IllegalStateException(); + case YES: + return InformativePrefix.GOOD; + case NO: + return InformativePrefix.BAD; + case MAYBE: + return InformativePrefix.NON_INFORMATIVE; + case UNKNOWN: + return InformativePrefix.NOT_COMPUTED; + default: + throw new IllegalStateException(); } } } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/check/RecursiveMemoizationChecker.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/check/RecursiveMemoizationChecker.java index 80e4c5f172da33f649d5531d4df165cb6d09f0a5..f1be37077488305a00095593f4ffc30fcb19828e 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/check/RecursiveMemoizationChecker.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/check/RecursiveMemoizationChecker.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl.check; import static org.eclipse.trace4cps.analysis.mtl.check.TabularExplanationTable.MAYBE; @@ -36,7 +37,6 @@ import org.eclipse.trace4cps.analysis.stl.StlFormula; import org.eclipse.trace4cps.core.impl.Interval; public final class RecursiveMemoizationChecker implements SingleFormulaChecker { - private List trace; private Set log; @@ -49,8 +49,10 @@ public final class RecursiveMemoizationChecker implements SingleFormulaChecker { private final Map depthMap = new HashMap(); + @Override public InformativePrefix check(List trace, MtlFormula phi, Set log, - boolean interpretAsPrefix) { + boolean interpretAsPrefix) + { this.trace = trace; if (log != null) { this.log = log; @@ -61,7 +63,7 @@ public final class RecursiveMemoizationChecker implements SingleFormulaChecker { List sub = MtlUtil.getSubformulas(phi); idMap.clear(); int i = 0; - for (MtlFormula f : sub) { + for (MtlFormula f: sub) { idMap.put(f, i); i++; } @@ -80,7 +82,7 @@ public final class RecursiveMemoizationChecker implements SingleFormulaChecker { private int fillDepthMap(MtlFormula phi) { int max = 0; - for (MtlFormula child : phi.getChildren()) { + for (MtlFormula child: phi.getChildren()) { max = Math.max(max, fillDepthMap(child)); } depthMap.put(phi, max); @@ -98,25 +100,26 @@ public final class RecursiveMemoizationChecker implements SingleFormulaChecker { /** * {@inheritDoc} */ + @Override public ExplanationTable getExplanation() { return l; } private int fillTable(MtlFormula f, int i) { if (f instanceof AtomicProposition) { - return fillAP((AtomicProposition) f, i); + return fillAP((AtomicProposition)f, i); } else if (f instanceof MTLnot) { - return fillNot((MTLnot) f, i); + return fillNot((MTLnot)f, i); } else if (f instanceof MTLand) { - return fillAnd((MTLand) f, i); + return fillAnd((MTLand)f, i); } else if (f instanceof MTLimply) { - return fillImply((MTLimply) f, i); + return fillImply((MTLimply)f, i); } else if (f instanceof MTLor) { - return fillOr((MTLor) f, i); + return fillOr((MTLor)f, i); } else if (f instanceof MTLuntil) { - return fillUntil((MTLuntil) f, i); + return fillUntil((MTLuntil)f, i); } else if (f instanceof StlFormula) { - return fillStlSubformula((StlFormula) f, i); + return fillStlSubformula((StlFormula)f, i); } else { throw new IllegalStateException("use of " + f.getClass().toString() + " constructs unsupported!"); } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/check/RegionImpl.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/check/RegionImpl.java index d783a5ec6f7b19817c0ebc23e137dfd5a2a2bcf4..73ac1f0b4612744b2abd70186127d81763107923 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/check/RegionImpl.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/check/RegionImpl.java @@ -7,13 +7,13 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl.check; -import org.eclipse.trace4cps.analysis.mtl.InformativePrefix; import org.eclipse.trace4cps.analysis.mtl.ExplanationTable.Region; +import org.eclipse.trace4cps.analysis.mtl.InformativePrefix; public final class RegionImpl implements Region { - private double startTime = -1; private double endTime = -1; @@ -38,22 +38,27 @@ public final class RegionImpl implements Region { this.endTime = timeStamp; } + @Override public int getStartIndex() { return startIndex; } + @Override public int getEndIndex() { return endIndex; } + @Override public double getStartTime() { return startTime; } + @Override public double getEndTime() { return endTime; } + @Override public InformativePrefix getValue() { return val; } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/check/SingleFormulaChecker.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/check/SingleFormulaChecker.java index b62516947ec81d85b90d917ed142756d1bef3dea..d6fa447ab392e78e1eb11a497f5d8e85cfeb10b7 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/check/SingleFormulaChecker.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/check/SingleFormulaChecker.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl.check; import java.util.List; @@ -18,7 +19,6 @@ import org.eclipse.trace4cps.analysis.mtl.MtlFormula; import org.eclipse.trace4cps.analysis.mtl.State; public interface SingleFormulaChecker { - InformativePrefix check(List trace, MtlFormula phi, Set log, boolean interpretAsPrefix); diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/check/TabularExplanationTable.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/check/TabularExplanationTable.java index 6c29705a9d6fb817e3604a39e3d6bff1c310691c..2b651ade5ad2a25184ee1410b23190c9be506d34 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/check/TabularExplanationTable.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/check/TabularExplanationTable.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl.check; import org.eclipse.trace4cps.analysis.mtl.ExplanationTable; @@ -14,7 +15,6 @@ import org.eclipse.trace4cps.analysis.mtl.InformativePrefix; import org.eclipse.trace4cps.analysis.mtl.MtlFormula; public interface TabularExplanationTable extends ExplanationTable { - public static final int YES = 1; public static final int NO = 2; diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/AbstractBinopMTLformula.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/AbstractBinopMTLformula.java index cf3522ac95b8c200df244f69a5f6d1c7a538b976..1d60e2263ce790fc93974777fbb63bcc2ad22bed 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/AbstractBinopMTLformula.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/AbstractBinopMTLformula.java @@ -7,12 +7,12 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl.impl; import org.eclipse.trace4cps.analysis.mtl.MtlFormula; public abstract class AbstractBinopMTLformula extends AbstractMTLformula { - public AbstractBinopMTLformula(MtlFormula left, MtlFormula right) { super(left, right); } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/AbstractMTLformula.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/AbstractMTLformula.java index 1aa71553fb01fd73438b2996b5c8607c5042274c..d847f9cda890bbf4523b50ffec8625298c1edc06 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/AbstractMTLformula.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/AbstractMTLformula.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl.impl; import java.util.ArrayList; @@ -15,12 +16,11 @@ import java.util.List; import org.eclipse.trace4cps.analysis.mtl.MtlFormula; public abstract class AbstractMTLformula implements MtlFormula { - protected final List children = new ArrayList(); public AbstractMTLformula(MtlFormula... c) { if (c != null) { - for (MtlFormula f : c) { + for (MtlFormula f: c) { children.add(f); } } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/DoubleIExp.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/DoubleIExp.java index 2938e21094724d0f10bd6d6c15a8baea59a892aa..b9064fa9be62be1a2e230ed3d96ae14d5698fad2 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/DoubleIExp.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/DoubleIExp.java @@ -7,12 +7,12 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl.impl; import java.util.Map; public class DoubleIExp implements IExp { - private final double value; public DoubleIExp(double value) { @@ -24,7 +24,7 @@ public class DoubleIExp implements IExp { } public long evaluateLong(Map valuation) { - return (long) value; + return (long)value; } public boolean isNaturalNumber() { diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/IExp.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/IExp.java index a3b5e27583066b35b70dd0cb763da1b547d1308c..3c955da7472547265af85484fe54470c8e4d2009 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/IExp.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/IExp.java @@ -7,12 +7,12 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl.impl; import java.util.Map; public interface IExp { - public enum Iop { PLUS("+"), MINUS("-"), MULT("*"), DIV("/"), MOD("%"); @@ -22,6 +22,7 @@ public interface IExp { this.rep = rep; } + @Override public String toString() { return rep; } @@ -33,7 +34,7 @@ public interface IExp { /** * A variable can only come from a top-level conjunction and is a natural number - * + * * @return whether a variable is used in the expression */ boolean hasVariable(); diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/IntIExp.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/IntIExp.java index aa6d97ec9a0e23067fa7037a1edb2314e4d5c006..822b5d0a9a85e5af0e48275567c5ae67d99fa012 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/IntIExp.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/IntIExp.java @@ -7,12 +7,12 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl.impl; import java.util.Map; public class IntIExp implements IExp { - private final long value; public IntIExp(long value) { diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/MTLand.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/MTLand.java index 8334516c5b4574675f982ef30c473c61de1c5db3..6917749d066e6eba98e886a31944de4e3fc3867d 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/MTLand.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/MTLand.java @@ -7,12 +7,12 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl.impl; import org.eclipse.trace4cps.analysis.mtl.MtlFormula; public class MTLand extends AbstractBinopMTLformula { - public MTLand(MtlFormula a, MtlFormula b) { super(a, b); } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/MTLimply.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/MTLimply.java index 2215656d5caee83a04c33c0074a3833839d43128..f5016f7aabfe06fc6ee78b2be570e4d8c42be185 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/MTLimply.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/MTLimply.java @@ -7,12 +7,12 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl.impl; import org.eclipse.trace4cps.analysis.mtl.MtlFormula; public class MTLimply extends AbstractBinopMTLformula { - public MTLimply(MtlFormula a, MtlFormula b) { super(a, b); } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/MTLnot.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/MTLnot.java index 658f279bdd255d89ec2f07046e619a9f8353ad14..e46ab315e8fed2d6b8c4694042fd39f47855b1d6 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/MTLnot.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/MTLnot.java @@ -7,13 +7,13 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl.impl; import org.eclipse.trace4cps.analysis.mtl.MtlFormula; import org.eclipse.trace4cps.core.impl.Interval; public class MTLnot extends AbstractMTLformula { - public MTLnot(MtlFormula p) { super(p); } @@ -25,7 +25,7 @@ public class MTLnot extends AbstractMTLformula { @Override public String toString() { if (getChild() instanceof MTLuntil) { - MTLuntil u = (MTLuntil) getChild(); + MTLuntil u = (MTLuntil)getChild(); Interval i = u.getInterval(); String interval = ""; if (!i.isTrivial()) { @@ -33,7 +33,7 @@ public class MTLnot extends AbstractMTLformula { } if (u.getLeft() instanceof MTLtrue) { if (u.getRight() instanceof MTLnot) { - MTLnot n = (MTLnot) u.getRight(); + MTLnot n = (MTLnot)u.getRight(); return "G" + interval + " " + n.getChild(); } else { return "G" + interval + " !" + u.getRight(); diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/MTLor.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/MTLor.java index a452cc0ed000519615f4303ab88466d544c50ebd..55be60d03b85e9e72a6b010a0ad2a23cd70082eb 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/MTLor.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/MTLor.java @@ -7,12 +7,12 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl.impl; import org.eclipse.trace4cps.analysis.mtl.MtlFormula; public class MTLor extends AbstractBinopMTLformula { - public MTLor(MtlFormula a, MtlFormula b) { super(a, b); } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/MTLtrue.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/MTLtrue.java index b3b885829cc085a0a35191abed975de1a1e7aca9..642eb4c2edc53a3977f56abfa7fc16ab9b8be689 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/MTLtrue.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/MTLtrue.java @@ -7,10 +7,10 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl.impl; public class MTLtrue extends AbstractMTLformula { - @Override public String toString() { return "true"; diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/MTLuntil.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/MTLuntil.java index a2e43fdd8ba1febb865b127a9303f3e68bc48149..e3300156c3c5be0a577eb49c7ba7158346bc7236 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/MTLuntil.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/MTLuntil.java @@ -7,13 +7,13 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl.impl; import org.eclipse.trace4cps.analysis.mtl.MtlFormula; import org.eclipse.trace4cps.core.impl.Interval; public class MTLuntil extends AbstractBinopMTLformula { - private final Interval interval; public MTLuntil(MtlFormula a, MtlFormula b, Interval i) { diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/OpIExp.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/OpIExp.java index 31c18192b686158a94063721161687ee81778c6a..0b438e6c30cc6cd18c730ad80280d86234cbed33 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/OpIExp.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/OpIExp.java @@ -7,12 +7,12 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl.impl; import java.util.Map; public class OpIExp implements IExp { - private final Iop op; private final IExp left; @@ -29,18 +29,18 @@ public class OpIExp implements IExp { double v1 = left.evaluate(valuation); double v2 = right.evaluate(valuation); switch (op) { - case PLUS: - return v1 + v2; - case MINUS: - return v1 - v2; - case MULT: - return v1 * v2; - case DIV: - return v1 / v2; - case MOD: - return v1 % v2; - default: - throw new IllegalStateException("Unknown operator: " + op); + case PLUS: + return v1 + v2; + case MINUS: + return v1 - v2; + case MULT: + return v1 * v2; + case DIV: + return v1 / v2; + case MOD: + return v1 % v2; + default: + throw new IllegalStateException("Unknown operator: " + op); } } @@ -48,18 +48,18 @@ public class OpIExp implements IExp { long v1 = left.evaluateLong(valuation); long v2 = right.evaluateLong(valuation); switch (op) { - case PLUS: - return v1 + v2; - case MINUS: - return v1 - v2; - case MULT: - return v1 * v2; - case DIV: - return v1 / v2; - case MOD: - return v1 % v2; - default: - throw new IllegalStateException("Unknown operator: " + op); + case PLUS: + return v1 + v2; + case MINUS: + return v1 - v2; + case MULT: + return v1 * v2; + case DIV: + return v1 / v2; + case MOD: + return v1 % v2; + default: + throw new IllegalStateException("Unknown operator: " + op); } } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/VarIExp.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/VarIExp.java index b353e37836f18e973277eabf69f61b830a547490..a051c5067e640efe1d8d97e9187755c6f4163907 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/VarIExp.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/mtl/impl/VarIExp.java @@ -7,12 +7,12 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.mtl.impl; import java.util.Map; public class VarIExp implements IExp { - private final String value; public VarIExp(String value) { @@ -23,16 +23,14 @@ public class VarIExp implements IExp { Long l = valuation.get(value); if (l == null) { throw new IllegalStateException("No value for free variable \"" + value + "\""); - } - return (double) l; + return (double)l; } public long evaluateLong(Map valuation) { Long l = valuation.get(value); if (l == null) { throw new IllegalStateException("No value for free variable \"" + value + "\""); - } return l; } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/resource/ResourceAnalysis.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/resource/ResourceAnalysis.java index e65d589f4e2ea87c18415c9b380ab50497c7a3eb..3e1c7872bc16fe72119f2230ba5494f80e7b6ceb 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/resource/ResourceAnalysis.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/resource/ResourceAnalysis.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.resource; import java.util.HashMap; @@ -23,21 +24,21 @@ import org.eclipse.trace4cps.core.ITrace; * This class provides a straightforward resource-usage analysis of a given {@link ITrace}. */ public class ResourceAnalysis { - private ResourceAnalysis() { } /** * Computes the resource-usage of selected resources. - * + * * @param trace the {@link ITrace} * @param selected the {@link IResource} instances to include * @param cumulative whether the result is shown as a cumulative value - * @return a map that for each selected resource gives a map that for a number of concurrent clients on - * the resource gives the amount of time (% of the trace time, possible cumulative) + * @return a map that for each selected resource gives a map that for a number of concurrent clients on the resource + * gives the amount of time (% of the trace time, possible cumulative) */ public static Map> compute(ITrace trace, List selected, - boolean cumulative) { + boolean cumulative) + { return convertHistos(getHistos(trace), selected, cumulative); } @@ -45,7 +46,7 @@ public class ResourceAnalysis { Map histos = new HashMap(); double min = Double.POSITIVE_INFINITY; double max = Double.NEGATIVE_INFINITY; - for (IClaim c : trace.getClaims()) { + for (IClaim c: trace.getClaims()) { IResource r = c.getResource(); ResourceClientHistogram h = histos.get(r); if (h == null) { @@ -57,16 +58,17 @@ public class ResourceAnalysis { min = Math.min(min, c.getStartTime().doubleValue()); max = Math.max(max, c.getEndTime().doubleValue()); } - for (ResourceClientHistogram h : histos.values()) { + for (ResourceClientHistogram h: histos.values()) { h.done(min, max); } return histos; } - private static Map> convertHistos( - Map histos, List selected, boolean cumulative) { + private static Map> + convertHistos(Map histos, List selected, boolean cumulative) + { Map> h = new HashMap>(); - for (Map.Entry e : histos.entrySet()) { + for (Map.Entry e: histos.entrySet()) { IResource r = e.getKey(); if (selected.contains(r)) { if (cumulative) { diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/resource/impl/ResourceClientHistogram.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/resource/impl/ResourceClientHistogram.java index 569d251e9bf86a1515c51b4fdd9d1c7ec29fad4f..4e06e685d63894ef88da44da421d29576f300e26 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/resource/impl/ResourceClientHistogram.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/resource/impl/ResourceClientHistogram.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.resource.impl; import java.util.ArrayList; @@ -20,9 +21,8 @@ import java.util.TreeMap; * This class provides a histogram of the time that the resource has n clients. */ public final class ResourceClientHistogram { - private static final Comparator COMP = new Comparator() { - + @Override public int compare(Event o1, Event o2) { return Double.compare(o1.timeStamp, o2.timeStamp); } @@ -40,7 +40,7 @@ public final class ResourceClientHistogram { /** * For building the histogram from a list of claims. - * + * * @param start start timestamp of a single claim * @param end end timestamp of a single claim */ @@ -86,7 +86,7 @@ public final class ResourceClientHistogram { /** * Finishes building the histogram. Needs to be called before {@link #getClientUsage()}. - * + * * @param lastTimeStamp the last timestamp in the trace */ public void done(double firstTimeStamp, double lastTimeStamp) { @@ -107,7 +107,7 @@ public final class ResourceClientHistogram { throw new IllegalStateException("timestamps from claims are before the first timestamp"); } process(firstTimeStamp, prevTimeStamp, 0); - for (Event e : events) { + for (Event e: events) { process(prevTimeStamp, e.timeStamp, cnt); prevTimeStamp = e.timeStamp; if (e.isStart) { @@ -122,11 +122,11 @@ public final class ResourceClientHistogram { process(prevTimeStamp, lastTimeStamp, cnt); // Create normalized double sum = 0d; - for (Double t : histogram.values()) { + for (Double t: histogram.values()) { sum += t; } double prevV = 0d; - for (Map.Entry e : histogram.entrySet()) { + for (Map.Entry e: histogram.entrySet()) { double v = (e.getValue() * 100d) / sum; normalizedHistogram.put(e.getKey(), v); normalizedCumulHistogram.put(e.getKey(), v + prevV); @@ -145,7 +145,6 @@ public final class ResourceClientHistogram { } private static final class Event { - private final double timeStamp; private boolean isStart; diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/signal/SignalModifier.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/signal/SignalModifier.java index a757a3706e8de55469a92b47e231402a1407c9ce..18aadb9abb8cf2426e5a9808efdd19008d01eb73 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/signal/SignalModifier.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/signal/SignalModifier.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.signal; import java.util.concurrent.TimeUnit; @@ -15,8 +16,7 @@ import java.util.concurrent.TimeUnit; * A signal modifier to modify the scaling of the signal, and the applied convolution. */ public class SignalModifier { - - public static SignalModifier NONE = new SignalModifier(1d); + public static final SignalModifier NONE = new SignalModifier(1d); private final double scaleFactor; @@ -26,7 +26,7 @@ public class SignalModifier { /** * Creates a new signal modifier without convolution. - * + * * @param scaleFactor the scaling */ public SignalModifier(double scaleFactor) { @@ -37,7 +37,7 @@ public class SignalModifier { /** * Creates a new signal modifier. - * + * * @param scaleFactor the scale factor * @param windowWidth the width of the convolution window ({@code <= 0}) means no convolution) * @param windowTimeUnit the time unit of the convolution window width diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/signal/SignalUtil.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/signal/SignalUtil.java index e3fcfc749ba2dfc2c27e64878d4a62bb3678d5d5..422742ece78d3f58664e2057f144bb507aa35b0d 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/signal/SignalUtil.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/signal/SignalUtil.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.signal; import java.util.ArrayList; @@ -27,17 +28,16 @@ import org.eclipse.trace4cps.core.impl.Interval; import org.eclipse.trace4cps.core.impl.TraceHelper; /** - * Utility methods for computing the Little's law signals of an {@link ITrace}. The signals here are all - * computed based on the {@link IClaim} instances of an {@link ITrace}. + * Utility methods for computing the Little's law signals of an {@link ITrace}. The signals here are all computed based + * on the {@link IClaim} instances of an {@link ITrace}. */ public class SignalUtil { - private SignalUtil() { } /** * Converts a time value from one unit to another. - * + * * @param dst the destination unit * @param v the value * @param src the source unit @@ -51,25 +51,25 @@ public class SignalUtil { return w; } - private static double getTraceWindowWidth(TimeUnit traceTimeUnit, double windowWidth, - TimeUnit windowTimeUnit) { + private static double getTraceWindowWidth(TimeUnit traceTimeUnit, double windowWidth, TimeUnit windowTimeUnit) { return convert(traceTimeUnit, windowWidth, windowTimeUnit); } /** - * Creates a latency signal based on grouping of events by an {@code idAtt} attribute: all events with the - * same value for this attribute are assumed to belong to the processing of a single object. - * + * Creates a latency signal based on grouping of events by an {@code idAtt} attribute: all events with the same + * value for this attribute are assumed to belong to the processing of a single object. + * * @param trace the trace * @param idAttribute the attribute used for grouping of the events * @param scaleUnit the unit in which the latency is expressed (unit of the range of the function, e.g., - * MILLISECOND) + * MILLISECOND) * @param windowWidth the width of the convolution window * @param windowUnit the time unit of the convolution window width * @return a signal for the latency of object processing */ public static IPsop getLatency(ITrace trace, String idAttribute, TimeUnit scaleUnit, double windowWidth, - TimeUnit windowUnit) { + TimeUnit windowUnit) + { double scaleFactor = convert(scaleUnit, 1, trace.getTimeUnit()); SignalModifier mod = new SignalModifier(scaleFactor, windowWidth, windowUnit); List wip = createWipEventSignal(trace, idAttribute); @@ -83,9 +83,9 @@ public class SignalUtil { } /** - * Creates a throughput signal based on grouping of events by an {@code idAtt} attribute: all events with - * the same value for this attribute are assumed to belong to the processing of a single object. - * + * Creates a throughput signal based on grouping of events by an {@code idAtt} attribute: all events with the same + * value for this attribute are assumed to belong to the processing of a single object. + * * @param trace the trace * @param idAttribute the attribute used for grouping of the events * @param scaleUnit 1 / the unit in which the throughput is expressed (e.g., per SECOND) @@ -93,18 +93,16 @@ public class SignalUtil { * @param windowUnit the time unit of the convolution window width * @return a signal for the throughput of object processing */ - public static IPsop getTP(ITrace trace, String idAtt, TimeUnit scaleUnit, double windowWidth, - TimeUnit windowUnit) { + public static IPsop getTP(ITrace trace, String idAtt, TimeUnit scaleUnit, double windowWidth, TimeUnit windowUnit) { double scaleFactor = convert(trace.getTimeUnit(), 1, scaleUnit); SignalModifier mod = new SignalModifier(scaleFactor, windowWidth, windowUnit); - return modifySignal(trace.getTimeUnit(), TraceHelper.getDomain(trace), - createTpEventSignal(trace, idAtt), mod); + return modifySignal(trace.getTimeUnit(), TraceHelper.getDomain(trace), createTpEventSignal(trace, idAtt), mod); } /** - * Creates a throughput signal based on events. Each event is assumed to represent the processing of a - * single object. NOTE: a convolution must be specified, i.e., {@code windowWidth > 0} - * + * Creates a throughput signal based on events. Each event is assumed to represent the processing of a single + * object. NOTE: a convolution must be specified, i.e., {@code windowWidth > 0} + * * @param traceTimeUnit the time unit of the trace (and thus also of the events) * @param dom the domain to which to project the result to * @param events the events for the throughput signal @@ -114,7 +112,8 @@ public class SignalUtil { * @return the event-based throughput signal */ public static IPsop getTP(TimeUnit traceTimeUnit, IInterval dom, List events, TimeUnit scaleUnit, - double windowWidth, TimeUnit windowUnit) { + double windowWidth, TimeUnit windowUnit) + { double scaleFactor = convert(traceTimeUnit, 1, scaleUnit); SignalModifier mod = new SignalModifier(scaleFactor, windowWidth, windowUnit); if (!mod.appliesConvolution()) { @@ -124,22 +123,21 @@ public class SignalUtil { } /** - * Creates a work-in-progress signal based on grouping of events by an {@code idAtt} attribute: all events - * with the same value for this attribute are assumed to belong to the processing of a single object. - * + * Creates a work-in-progress signal based on grouping of events by an {@code idAtt} attribute: all events with the + * same value for this attribute are assumed to belong to the processing of a single object. + * * @param trace the trace * @param idAttribute the attribute used for grouping of the events * @param mod the modifier (see {@link SignalModifier#forWip(double, TimeUnit)}) * @return a signal for the wip of object processing */ public static IPsop getWip(ITrace trace, String idAtt, SignalModifier mod) { - return modifySignal(trace.getTimeUnit(), TraceHelper.getDomain(trace), - createWipEventSignal(trace, idAtt), mod); + return modifySignal(trace.getTimeUnit(), TraceHelper.getDomain(trace), createWipEventSignal(trace, idAtt), mod); } /** * Creates a signal with the number of concurrent clients on a given resource. - * + * * @param trace the trace * @param resource the resource * @param mod the signal modifier @@ -147,12 +145,12 @@ public class SignalUtil { */ public static IPsop getResourceClients(ITrace trace, IResource resource, SignalModifier mod) { return modifySignal(trace.getTimeUnit(), TraceHelper.getDomain(trace), - createResourceUtilizationSignal(trace, resource), mod); + createResourceUtilizationSignal(trace, resource), mod); } /** * Creates a signal with the total claimed amount of a given resource. - * + * * @param trace the trace * @param resource the resource * @param mod the signal modifier @@ -160,11 +158,12 @@ public class SignalUtil { */ public static IPsop getResourceAmount(ITrace trace, IResource resource, SignalModifier mod) { return modifySignal(trace.getTimeUnit(), TraceHelper.getDomain(trace), - createResourceAmountSignal(trace, resource), mod); + createResourceAmountSignal(trace, resource), mod); } - private static IPsop modifySignal(TimeUnit traceTimeUnit, IInterval dom, - List events, SignalModifier mod) { + private static IPsop modifySignal(TimeUnit traceTimeUnit, IInterval dom, List events, + SignalModifier mod) + { if (mod.appliesConvolution()) { return applyConvolution(traceTimeUnit, dom, mod, events); } else { @@ -172,14 +171,14 @@ public class SignalUtil { } } - private static IPsop applyInstantaneous(IInterval dom, SignalModifier mod, - List events) { + private static IPsop applyInstantaneous(IInterval dom, SignalModifier mod, List events) { List inst = EventSignalUtil.computeInstantaneous(events, mod.getScale(), dom); return EventSignalUtil.toIPsop(inst); } private static IPsop applyConvolution(TimeUnit traceTimeUnit, IInterval tdom, SignalModifier mod, - List lsfs) { + List lsfs) + { double scale = mod.getScale(); double w = getTraceWindowWidth(traceTimeUnit, mod.getWindowWidth(), mod.getWindowTimeUnit()); Interval dom = new Interval(tdom.lb(), false, tdom.ub().doubleValue() + w * 1.1, true); @@ -187,13 +186,13 @@ public class SignalUtil { } /** - * Returns a list of constant fragments with value 1 (thus counting the number of objects that are being - * processed). The fragments are ordered ascending by their start time. + * Returns a list of constant fragments with value 1 (thus counting the number of objects that are being processed). + * The fragments are ordered ascending by their start time. */ private static List createWipEventSignal(ITrace trace, String idAtt) { Map timeStampsAndValue = createTimeStampValueMap(trace, idAtt); List events = new ArrayList<>(); - for (Map.Entry e : timeStampsAndValue.entrySet()) { + for (Map.Entry e: timeStampsAndValue.entrySet()) { double[] ts = e.getValue(); events.add(new LinearSignalFragment(ts[0], ts[1], 1d, 1d)); } @@ -202,13 +201,13 @@ public class SignalUtil { } /** - * Returns a list of constant fragments with value 1/(t1-t0), which is a measure for the items processed - * per timeunit (throughput). The fragments are ordered ascending by their start time. + * Returns a list of constant fragments with value 1/(t1-t0), which is a measure for the items processed per + * timeunit (throughput). The fragments are ordered ascending by their start time. */ private static List createTpEventSignal(ITrace trace, String idAtt) { Map timeStampsAndValue = createTimeStampValueMap(trace, idAtt); List events = new ArrayList<>(); - for (Map.Entry e : timeStampsAndValue.entrySet()) { + for (Map.Entry e: timeStampsAndValue.entrySet()) { double[] ts = e.getValue(); double val = 1d / (ts[1] - ts[0]); events.add(new LinearSignalFragment(ts[0], ts[1], val, val)); @@ -219,11 +218,10 @@ public class SignalUtil { /** * @param list a list of events, sorted ascending on their timestamp - * @return */ private static List createTpEventSignal(List list) { List events = new ArrayList<>(); - for (IEvent e : list) { + for (IEvent e: list) { events.add(new LinearSignalFragment(e.getTimestamp().doubleValue(), 1d)); } return events; @@ -231,7 +229,7 @@ public class SignalUtil { private static Map createTimeStampValueMap(ITrace trace, String idAtt) { Map timeStampsAndValue = new HashMap<>(); - for (IEvent e : trace.getEvents()) { + for (IEvent e: trace.getEvents()) { if (e.getAttributeValue(idAtt) != null) { double[] vals = getOrCreate(idAtt, timeStampsAndValue, e); vals[0] = Math.min(vals[0], e.getTimestamp().doubleValue()); @@ -270,13 +268,12 @@ public class SignalUtil { return idAtt + "=" + val; } - private static List createResourceUtilizationSignal(ITrace trace, - IResource resource) { + private static List createResourceUtilizationSignal(ITrace trace, IResource resource) { List events = new ArrayList(); - for (IClaim c : trace.getClaims()) { + for (IClaim c: trace.getClaims()) { if (c.getResource().equals(resource)) { - events.add(new LinearSignalFragment(c.getStartTime().doubleValue(), - c.getEndTime().doubleValue(), 1d, 1d)); + events.add( + new LinearSignalFragment(c.getStartTime().doubleValue(), c.getEndTime().doubleValue(), 1d, 1d)); } } EventSignalUtil.sortStartAsc(events); @@ -285,12 +282,12 @@ public class SignalUtil { private static List createResourceAmountSignal(ITrace trace, IResource resource) { List events = new ArrayList(); - for (IClaim c : trace.getClaims()) { + for (IClaim c: trace.getClaims()) { if (c.getResource().equals(resource)) { double v = c.getAmount().doubleValue(); if (v > 0d) { - events.add(new LinearSignalFragment(c.getStartTime().doubleValue(), - c.getEndTime().doubleValue(), v, v)); + events.add(new LinearSignalFragment(c.getStartTime().doubleValue(), c.getEndTime().doubleValue(), v, + v)); } } } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/signal/impl/EventSignalUtil.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/signal/impl/EventSignalUtil.java index 1b165b1b81776c5a30d8c2875774c276d9ab6c14..183d928a8139b271606788a33d59f277931607c3 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/signal/impl/EventSignalUtil.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/signal/impl/EventSignalUtil.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.signal.impl; import java.util.ArrayList; @@ -22,18 +23,16 @@ import org.eclipse.trace4cps.core.impl.Psop; import org.eclipse.trace4cps.core.impl.PsopFragment; public final class EventSignalUtil { - private EventSignalUtil() { } /** * Sorts ascending with respect to the start timestamp of the event signal instances. - * + * * @param events a list of event signal instances */ public static void sortStartAsc(List events) { Collections.sort(events, new Comparator() { - @Override public int compare(LinearSignalFragment o1, LinearSignalFragment o2) { return Double.compare(o1.getT0(), o2.getT0()); @@ -46,7 +45,7 @@ public final class EventSignalUtil { */ public static Psop toIPsop(List events) { Psop r = new Psop(); - for (LinearSignalFragment e : events) { + for (LinearSignalFragment e: events) { Interval i = new Interval(e.getT0(), false, e.getT1(), true); r.add(new PsopFragment(e.getY0(), e.getCoefficient(), 0d, i)); } @@ -54,15 +53,15 @@ public final class EventSignalUtil { } /** - * @param eventSignal a list of possibly overlapping {@link LinearSignalFragment} instances; all must be - * constant + * @param eventSignal a list of possibly overlapping {@link LinearSignalFragment} instances; all must be constant * @param scale the scale factor of the result; e.g., using 60 gives the value per 60 time units * @param dom the domain for which to compute the result * @return a list of {@link LinearSignalFragment} instances that represents the sum of the given list of - * {@link LinearSignalFragment} instances + * {@link LinearSignalFragment} instances */ - public static List computeInstantaneous(List eventSignal, - double scale, IInterval dom) { + public static List computeInstantaneous(List eventSignal, double scale, + IInterval dom) + { List events = createEventList(eventSignal); List r = createConstantSignal(scale, events); return setDomain(r, dom, true); @@ -70,15 +69,15 @@ public final class EventSignalUtil { /** * @param events the events for which to compute the sliding-window average; these must all be constant! - * @param scale the result is multiplied with this scale factor; e.g., using 60 gives the sliding window - * average per 60 time units - * @param w the width of the convolution window: larger means smoother graphs, 0 gives the instantaneous - * value + * @param scale the result is multiplied with this scale factor; e.g., using 60 gives the sliding window average per + * 60 time units + * @param w the width of the convolution window: larger means smoother graphs, 0 gives the instantaneous value * @param dom the domain of the result * @return the resulting psop */ - public static final IPsop convoluteScaleAndProject(List events, double scale, - double w, Interval dom) { + public static final IPsop convoluteScaleAndProject(List events, double scale, double w, + Interval dom) + { List cl = convolution(events, w); cl = scale(cl, scale); return toIPsop(setDomain(cl, dom, true)); @@ -87,10 +86,10 @@ public final class EventSignalUtil { /** * @param dividend must be constant fragments * @param divisor must be constant fragments - * @return */ public static List divide(List dividend, - List divisor, double undefinedValue) { + List divisor, double undefinedValue) + { List l1 = createEventList(dividend); List l2 = createEventList(divisor); if (l1.isEmpty() || l2.isEmpty()) { @@ -127,7 +126,7 @@ public final class EventSignalUtil { private static void splitAtEvents(List cl, List el) { int i = 0; - for (Event e : el) { + for (Event e: el) { // find the next fragment that contains e.t while (cl.get(i).getT1() < e.t) { i++; @@ -143,7 +142,7 @@ public final class EventSignalUtil { List r = new ArrayList<>(); Event prev = null; double value = 0d; - for (Event e : events) { + for (Event e: events) { if (prev != null) { value += (prev.delta * scale); r.add(new LinearSignalFragment(prev.t, e.t, value, value)); @@ -156,7 +155,7 @@ public final class EventSignalUtil { private static List createEventList(List eventSignal) { // precondition: all constant fragments List events = new ArrayList(); - for (LinearSignalFragment s : eventSignal) { + for (LinearSignalFragment s: eventSignal) { if (s.isInstantaneousEvent()) { throw new UnsupportedOperationException("instantaneous events not suppprted"); } @@ -171,14 +170,13 @@ public final class EventSignalUtil { /** * Scales the given linear signal fragments: multiplied by {@code c} - * + * * @param fl the list of linear signal fragments. - * @param c * @return the scaled signal */ public static List scale(List fl, double c) { List r = new ArrayList(); - for (LinearSignalFragment f : fl) { + for (LinearSignalFragment f: fl) { r.add(new LinearSignalFragment(f.getT0(), f.getT1(), f.getY0() * c, f.getY1() * c)); } return r; @@ -188,7 +186,7 @@ public final class EventSignalUtil { // checkAndPad(fl, false); List result = new ArrayList<>(); List conv = new ArrayList<>(); - for (LinearSignalFragment f : fl) { + for (LinearSignalFragment f: fl) { conv.clear(); convolutionWithBlock(conv, f, w); addTo(result, conv); @@ -213,7 +211,7 @@ public final class EventSignalUtil { // non-overlapping. // This is guaranteed from the beginning as a single convolution result is added // Now guarantee that the following merge function preserves it: - for (LinearSignalFragment f : l) { + for (LinearSignalFragment f: l) { double t0cl = result.get(0).getT0(); double t1cl = result.get(result.size() - 1).getT1(); // There are six cases how f can overlap with cl @@ -251,8 +249,9 @@ public final class EventSignalUtil { private static void checkAndPad(List fl, boolean pad) { // non-overlapping and consecutive + int i = 0; int ub = fl.size() - 1; - for (int i = 0; i < ub; i++) { + while (i < ub) { LinearSignalFragment f1 = fl.get(i); LinearSignalFragment f2 = fl.get(i + 1); if (f1.getT1() > f2.getT0()) { @@ -267,23 +266,23 @@ public final class EventSignalUtil { i++; ub++; } + i++; } } /** - * Convolutes the given {@link ConstantSignalFragment} with a block function on domain [b0, b0 + w] with - * value 1/w. The result is put into the given list of {@link LinearSignalFragment} instances to avoid - * allocation and deallocation of many List instances. - *

    - * By default, b0 = 0, such that this gives the average value over the last w time units. If b0 = - w/2 - * for instance, then the average value around t with window width w is computed. - * + * Convolutes the given {@link ConstantSignalFragment} with a block function on domain [b0, b0 + w] with value 1/w. + * The result is put into the given list of {@link LinearSignalFragment} instances to avoid allocation and + * deallocation of many List instances. + *

    + * By default, b0 = 0, such that this gives the average value over the last w time units. If b0 = - w/2 for + * instance, then the average value around t with window width w is computed. + * * @param r the result list * @param f the event signal to convolute * @param w the width of the block function */ - private static void convolutionWithBlock(List r, LinearSignalFragment f, - double w) { + private static void convolutionWithBlock(List r, LinearSignalFragment f, double w) { if (!f.isConstant()) { throw new IllegalStateException("convolution only supported for constant signal fragments"); } @@ -329,8 +328,9 @@ public final class EventSignalUtil { } private static List merge(List events) { + int i = 0; List r = new ArrayList(); - for (int i = 0; i < events.size(); i++) { + while (i < events.size()) { Event ei = events.get(i); int j = i + 1; double extraDelta = 0d; @@ -340,12 +340,14 @@ public final class EventSignalUtil { } i = j - 1; r.add(new Event(ei.t, ei.delta + extraDelta)); + i++; } return r; } private static List setDomain(List ls, IInterval dom, - boolean padWithZeros) { + boolean padWithZeros) + { if (ls.isEmpty()) { throw new IllegalArgumentException("cannot set the domain of an empty signal"); } @@ -362,8 +364,7 @@ public final class EventSignalUtil { return projectTo(ls, dom.lb().doubleValue(), dom.ub().doubleValue()); } - private static List projectTo(List ls, double tmin, - double tmax) { + private static List projectTo(List ls, double tmin, double tmax) { int i1 = split(ls, tmin); int i2 = split(ls, tmax); // if (i1 == -1) { @@ -411,7 +412,6 @@ public final class EventSignalUtil { } private static final class Event implements Comparable { - private final double t; private final double delta; @@ -431,5 +431,4 @@ public final class EventSignalUtil { return "Event [t=" + t + ", delta=" + delta + "]"; } } - } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/signal/impl/LinearSignalFragment.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/signal/impl/LinearSignalFragment.java index 3944cdadcde1999ff7c036bcaa4a296e22a80a61..e4a59edcd78dd9fee712b517fcfc42439aa6f1a7 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/signal/impl/LinearSignalFragment.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/signal/impl/LinearSignalFragment.java @@ -7,13 +7,13 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.signal.impl; /** * A linear fragment to construct piecewise-linear signals. Immutable. */ public class LinearSignalFragment { - private final double t0; private final double t1; @@ -24,9 +24,6 @@ public class LinearSignalFragment { /** * Constructs an instantaneaous fragment. - * - * @param t - * @param y */ public LinearSignalFragment(double t, double y) { this.t0 = t; diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/signal/impl/PsopHelper.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/signal/impl/PsopHelper.java index c19e70dee77e746862421f48dae8dcb3ebac7ea7..812aee455a9ac78c8effc3515748c97df572e47e 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/signal/impl/PsopHelper.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/signal/impl/PsopHelper.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.signal.impl; import java.math.BigDecimal; @@ -31,7 +32,6 @@ import org.eclipse.trace4cps.core.impl.Resource; * A utility class with methods for {@link IPsop} instances. */ public class PsopHelper { - private PsopHelper() { } @@ -41,14 +41,12 @@ public class PsopHelper { public static IPsop translate(IPsop p, double delta) { Psop p2 = new Psop(); - for (Map.Entry e : p.getAttributes().entrySet()) { + for (Map.Entry e: p.getAttributes().entrySet()) { p2.setAttribute(e.getKey(), e.getValue()); } - for (IPsopFragment f : p.getFragments()) { - double lb = - BigDecimal.valueOf(f.dom().lb().doubleValue()).add(BigDecimal.valueOf(delta)).doubleValue(); - double ub = - BigDecimal.valueOf(f.dom().ub().doubleValue()).add(BigDecimal.valueOf(delta)).doubleValue(); + for (IPsopFragment f: p.getFragments()) { + double lb = BigDecimal.valueOf(f.dom().lb().doubleValue()).add(BigDecimal.valueOf(delta)).doubleValue(); + double ub = BigDecimal.valueOf(f.dom().ub().doubleValue()).add(BigDecimal.valueOf(delta)).doubleValue(); if (lb < ub) { // rounding errors can cause lb >= ub; in that case we ignore the fragment as it // was really small IInterval i2 = new Interval(lb, f.dom().isOpenLb(), ub, f.dom().isOpenUb()); @@ -84,7 +82,7 @@ public class PsopHelper { public static IPsop add(IPsop p, double cnst) { Psop r = new Psop(); - for (IPsopFragment f : p.getFragments()) { + for (IPsopFragment f: p.getFragments()) { double c = BigDecimal.valueOf(f.getC().doubleValue()).add(BigDecimal.valueOf(cnst)).doubleValue(); r.add(new PsopFragment(c, f.getB(), f.getA(), f.dom())); } @@ -111,20 +109,20 @@ public class PsopHelper { IPsopFragment f1 = g1.getFragments().get(i); IPsopFragment f2 = g2.getFragments().get(i); if (isAdd) { - double c = BigDecimal.valueOf(f1.getC().doubleValue()) - .add(BigDecimal.valueOf(f2.getC().doubleValue())).doubleValue(); - double b = BigDecimal.valueOf(f1.getB().doubleValue()) - .add(BigDecimal.valueOf(f2.getB().doubleValue())).doubleValue(); - double a = BigDecimal.valueOf(f1.getA().doubleValue()) - .add(BigDecimal.valueOf(f2.getA().doubleValue())).doubleValue(); + double c = BigDecimal.valueOf(f1.getC().doubleValue()).add(BigDecimal.valueOf(f2.getC().doubleValue())) + .doubleValue(); + double b = BigDecimal.valueOf(f1.getB().doubleValue()).add(BigDecimal.valueOf(f2.getB().doubleValue())) + .doubleValue(); + double a = BigDecimal.valueOf(f1.getA().doubleValue()).add(BigDecimal.valueOf(f2.getA().doubleValue())) + .doubleValue(); r.add(new PsopFragment(c, b, a, f1.dom())); } else { double c = BigDecimal.valueOf(f1.getC().doubleValue()) - .subtract(BigDecimal.valueOf(f2.getC().doubleValue())).doubleValue(); + .subtract(BigDecimal.valueOf(f2.getC().doubleValue())).doubleValue(); double b = BigDecimal.valueOf(f1.getB().doubleValue()) - .subtract(BigDecimal.valueOf(f2.getB().doubleValue())).doubleValue(); + .subtract(BigDecimal.valueOf(f2.getB().doubleValue())).doubleValue(); double a = BigDecimal.valueOf(f1.getA().doubleValue()) - .subtract(BigDecimal.valueOf(f2.getA().doubleValue())).doubleValue(); + .subtract(BigDecimal.valueOf(f2.getA().doubleValue())).doubleValue(); r.add(new PsopFragment(c, b, a, f1.dom())); } } @@ -133,13 +131,10 @@ public class PsopHelper { public static IPsop mult(IPsop p, double cnst) { Psop r = new Psop(); - for (IPsopFragment f : p.getFragments()) { - double c = - BigDecimal.valueOf(f.getC().doubleValue()).multiply(BigDecimal.valueOf(cnst)).doubleValue(); - double b = - BigDecimal.valueOf(f.getB().doubleValue()).multiply(BigDecimal.valueOf(cnst)).doubleValue(); - double a = - BigDecimal.valueOf(f.getA().doubleValue()).multiply(BigDecimal.valueOf(cnst)).doubleValue(); + for (IPsopFragment f: p.getFragments()) { + double c = BigDecimal.valueOf(f.getC().doubleValue()).multiply(BigDecimal.valueOf(cnst)).doubleValue(); + double b = BigDecimal.valueOf(f.getB().doubleValue()).multiply(BigDecimal.valueOf(cnst)).doubleValue(); + double a = BigDecimal.valueOf(f.getA().doubleValue()).multiply(BigDecimal.valueOf(cnst)).doubleValue(); r.add(new PsopFragment(c, b, a, f.dom())); } return r; @@ -157,7 +152,7 @@ public class PsopHelper { public static IPsop createDerivativeOf(IPsop p) { Psop der = new Psop(); der.setAttributes(p.getAttributes()); - for (IPsopFragment f : p.getFragments()) { + for (IPsopFragment f: p.getFragments()) { IPsopFragment fn = new PsopFragment(f.getB(), 2 * f.getA().doubleValue(), 0d, f.dom()); der.add(fn); } @@ -181,7 +176,7 @@ public class PsopHelper { public static Psop copy(IPsop p) { Psop f = new Psop(); f.setAttributes(p.getAttributes()); - for (IPsopFragment frag : p.getFragments()) { + for (IPsopFragment frag: p.getFragments()) { f.addAtEnd(copy(frag)); } return f; @@ -213,7 +208,7 @@ public class PsopHelper { throw new IllegalStateException("function is empty"); } MinMaxResult r = new MinMaxResult(); - for (IPsopFragment f : p.getFragments()) { + for (IPsopFragment f: p.getFragments()) { r.combineWith(computeMinMax(f)); } return r.getMin(); @@ -224,7 +219,7 @@ public class PsopHelper { throw new IllegalStateException("function is empty"); } MinMaxResult r = new MinMaxResult(); - for (IPsopFragment f : p.getFragments()) { + for (IPsopFragment f: p.getFragments()) { r.combineWith(computeMinMax(f)); } return r.getMax(); @@ -232,9 +227,6 @@ public class PsopHelper { /** * Possibly splits the fragments in the given Psop. - * - * @param p - * @return */ public static List createMonotonicSegmentation(IPsop p) { int startIndex = 0; @@ -263,7 +255,6 @@ public class PsopHelper { startIndex = endIndex; i++; } else { - if (shape == Shape.CONSTANT) { endIndex++; i++; @@ -306,17 +297,18 @@ public class PsopHelper { return Math.abs(frag.getC().doubleValue() - valueAt(prev, prev.dom().ub()).doubleValue()) > 1e-9; } - private static void splitFragment(List fragments, int fragIndex, IPsopFragment frag, - Number xSplit) { + private static void splitFragment(List fragments, int fragIndex, IPsopFragment frag, Number xSplit) { Number c = valueAt(frag, xSplit); Number b = valueDerivativeAt(frag, xSplit); splitFragment(fragments, fragIndex, frag, xSplit, c, b); } - private static void splitFragment(List fragments, int fragIndex, IPsopFragment frag, - Number xSplit, Number c, Number b) { + private static void splitFragment(List fragments, int fragIndex, IPsopFragment frag, Number xSplit, + Number c, Number b) + { if (xSplit.doubleValue() == frag.dom().lb().doubleValue() - || xSplit.doubleValue() == frag.dom().ub().doubleValue()) { + || xSplit.doubleValue() == frag.dom().ub().doubleValue()) + { return; } Number lb = frag.dom().lb(); @@ -358,8 +350,8 @@ public class PsopHelper { Number c = valueAt(frag, d.lb()); Number b = valueDerivativeAt(frag, d.lb()); p.getFragments().remove(i); - p.getFragments().add(i, new PsopFragment(c, b, frag.getA(), - new Interval(d.lb(), false, frag.dom().ub(), true))); + p.getFragments().add(i, + new PsopFragment(c, b, frag.getA(), new Interval(d.lb(), false, frag.dom().ub(), true))); } break; } @@ -398,10 +390,10 @@ public class PsopHelper { } /** - * Aligns this IPsop with the given IPsop. The domain of the result function is the intersection of the - * domains of this IPsop and the given IPsop. The fragments are split in such a way that they align with - * the fragments of the given IPsop. - * + * Aligns this IPsop with the given IPsop. The domain of the result function is the intersection of the domains of + * this IPsop and the given IPsop. The fragments are split in such a way that they align with the fragments of the + * given IPsop. + * * @param p the IPsop to align * @param g the IPsop to align to */ @@ -501,9 +493,9 @@ public class PsopHelper { /** * Requires that both fragments have the same time domain. - *

    + *

    * Empty list iff constant distance, or no intersections - * + * * @param f1 fragment 1 * @param f2 fragment 2 * @return a list of domain points where the fragments intersect @@ -556,51 +548,51 @@ public class PsopHelper { double t0 = PsopHelper.getDomainLowerBound(signal).doubleValue(); boolean sat = PsopHelper.getStartValue(signal).doubleValue() >= 0d; - for (ShapeSegment seg : PsopHelper.createMonotonicSegmentation(signal)) { + for (ShapeSegment seg: PsopHelper.createMonotonicSegmentation(signal)) { switch (seg.getShape()) { - case CONSTANT: - double startT = signal.getFragments().get(seg.getBeginFragment()).dom().lb().doubleValue(); - double value = signal.getFragments().get(seg.getBeginFragment()).getC().doubleValue(); - if ((sat && value < 0d) || (!sat && value >= 0d)) { - createClaim(claims, claimName, r, t0, startT, sat); - t0 = startT; - sat = !sat; - } - break; - case INCREASING: - if (!sat) { - // check whether we get sat - for (int i = seg.getBeginFragment(); i <= seg.getEndFragment(); i++) { - IPsopFragment frag = signal.getFragments().get(i); - double v1 = PsopHelper.valueAt(frag, frag.dom().ub()).doubleValue(); - if (v1 >= 0d) { - double t1 = PsopHelper.argZeroValue(frag).doubleValue(); - createClaim(claims, claimName, r, t0, t1, sat); - t0 = t1; - sat = !sat; - break; + case CONSTANT: + double startT = signal.getFragments().get(seg.getBeginFragment()).dom().lb().doubleValue(); + double value = signal.getFragments().get(seg.getBeginFragment()).getC().doubleValue(); + if ((sat && value < 0d) || (!sat && value >= 0d)) { + createClaim(claims, claimName, r, t0, startT, sat); + t0 = startT; + sat = !sat; + } + break; + case INCREASING: + if (!sat) { + // check whether we get sat + for (int i = seg.getBeginFragment(); i <= seg.getEndFragment(); i++) { + IPsopFragment frag = signal.getFragments().get(i); + double v1 = PsopHelper.valueAt(frag, frag.dom().ub()).doubleValue(); + if (v1 >= 0d) { + double t1 = PsopHelper.argZeroValue(frag).doubleValue(); + createClaim(claims, claimName, r, t0, t1, sat); + t0 = t1; + sat = !sat; + break; + } } } - } - break; - case DECREASING: - if (sat) { - // check whether we get unsat - for (int i = seg.getBeginFragment(); i <= seg.getEndFragment(); i++) { - IPsopFragment frag = signal.getFragments().get(i); - double v1 = PsopHelper.valueAt(frag, frag.dom().ub()).doubleValue(); - if (v1 < 0d) { - double t1 = PsopHelper.argZeroValue(frag).doubleValue(); - createClaim(claims, claimName, r, t0, t1, sat); - t0 = t1; - sat = !sat; - break; + break; + case DECREASING: + if (sat) { + // check whether we get unsat + for (int i = seg.getBeginFragment(); i <= seg.getEndFragment(); i++) { + IPsopFragment frag = signal.getFragments().get(i); + double v1 = PsopHelper.valueAt(frag, frag.dom().ub()).doubleValue(); + if (v1 < 0d) { + double t1 = PsopHelper.argZeroValue(frag).doubleValue(); + createClaim(claims, claimName, r, t0, t1, sat); + t0 = t1; + sat = !sat; + break; + } } } - } - break; - default: - throw new IllegalStateException(); + break; + default: + throw new IllegalStateException(); } } // add the last claim @@ -611,7 +603,6 @@ public class PsopHelper { } private static Number argZeroValue(IPsopFragment f) { - if (f.getShape() == Shape.CONSTANT) { if (f.getC().doubleValue() == 0d) { return f.dom().lb(); @@ -647,8 +638,7 @@ public class PsopHelper { } } - private static void createClaim(List claims, String name, Resource r, double t0, double t1, - boolean sat) { + private static void createClaim(List claims, String name, Resource r, double t0, double t1, boolean sat) { Claim c = new Claim(t0, t1, r, 1); c.setAttribute("phi", name); c.setAttribute("type", "STL"); @@ -658,7 +648,6 @@ public class PsopHelper { } public static final class MinMaxResult { - private double min = Double.POSITIVE_INFINITY; private double max = Double.NEGATIVE_INFINITY; @@ -710,11 +699,10 @@ public class PsopHelper { } /** - * Immutable. A block of consecutive indices of {@link PsopFragment} instances which, when considered as a - * whole, have an INCREASING, DECREASING or CONSTANT shape. Begin and end indices are inclusive. + * Immutable. A block of consecutive indices of {@link PsopFragment} instances which, when considered as a whole, + * have an INCREASING, DECREASING or CONSTANT shape. Begin and end indices are inclusive. */ public static final class ShapeSegment { - private final int beginFragment; private final int endFragment; diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/StlBuilder.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/StlBuilder.java index e72da707fffc7f486107d28e00b97d3882b4288f..d77874580642cb74a5d9159ce764130b4845e22e 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/StlBuilder.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/StlBuilder.java @@ -7,23 +7,23 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.stl; import org.eclipse.trace4cps.analysis.stl.impl.StlBinBool; +import org.eclipse.trace4cps.analysis.stl.impl.StlBinBool.BinOp; import org.eclipse.trace4cps.analysis.stl.impl.StlEq; import org.eclipse.trace4cps.analysis.stl.impl.StlGeq; import org.eclipse.trace4cps.analysis.stl.impl.StlLeq; import org.eclipse.trace4cps.analysis.stl.impl.StlNeg; import org.eclipse.trace4cps.analysis.stl.impl.StlTrue; import org.eclipse.trace4cps.analysis.stl.impl.StlUntil; -import org.eclipse.trace4cps.analysis.stl.impl.StlBinBool.BinOp; import org.eclipse.trace4cps.core.IPsop; /** * This utility class provides methods to build {@link StlFormula} instances. */ public class StlBuilder { - private static final StlFormula T = new StlTrue(); private StlBuilder() { @@ -55,7 +55,7 @@ public class StlBuilder { */ public static StlFormula NOT(StlFormula f) { if (f instanceof StlNeg) { - return ((StlNeg) f).getFormula(); + return ((StlNeg)f).getFormula(); } return new StlNeg(f); } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/StlException.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/StlException.java index 69d2a6bc43cb5a9d7cb6216068aa9f50abb22276..5ed5038683d6b834fda4c93ac82321c8b9b1bc7a 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/StlException.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/StlException.java @@ -7,12 +7,12 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.stl; import org.eclipse.trace4cps.analysis.AnalysisException; public class StlException extends AnalysisException { - private static final long serialVersionUID = 1L; public StlException() { diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/StlFormula.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/StlFormula.java index 7b8a6e3d51fdac24c551d0389145bfc90bab9546..419622003a2c7655eb690c6979e792aea771db18 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/StlFormula.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/StlFormula.java @@ -7,19 +7,18 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.stl; import org.eclipse.trace4cps.analysis.mtl.MtlFormula; import org.eclipse.trace4cps.core.IPsop; /** - * A Signal Temporal Logic formula. Its space-robustness is given by the {@link #getRho()} method. Instances - * are created by the {@link StlBuilder} type. The {@link MtlFormula} is extended so that STL formulas can be - * used as subformulas of an MTL formula. This realizes (a subset of) the logic STL-mx of the FORMATS 2019 - * paper by T. Ferrere et al. + * A Signal Temporal Logic formula. Its space-robustness is given by the {@link #getRho()} method. Instances are created + * by the {@link StlBuilder} type. The {@link MtlFormula} is extended so that STL formulas can be used as subformulas of + * an MTL formula. This realizes (a subset of) the logic STL-mx of the FORMATS 2019 paper by T. Ferrere et al. */ public interface StlFormula extends MtlFormula { - /** * @return the space robustness of the formula */ diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/AbstractStlFormula.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/AbstractStlFormula.java index 796a76d1242efd26e4a284bcc285d815220cfc58..d6944f01b809b80c4fc5f06dcbb431c80e0c0ee8 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/AbstractStlFormula.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/AbstractStlFormula.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.stl.impl; import org.eclipse.trace4cps.analysis.signal.impl.PsopHelper; @@ -14,7 +15,6 @@ import org.eclipse.trace4cps.analysis.stl.StlFormula; import org.eclipse.trace4cps.core.IPsop; public abstract class AbstractStlFormula implements StlFormula { - private IPsop signal; @Override diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/STLUtil.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/STLUtil.java index 6169e0f7d88c515df61dbc5e84c10108ff485b8a..d110fc9aa7b2263f6f005cc9bb222e3a1c654794 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/STLUtil.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/STLUtil.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.stl.impl; import java.util.Collections; @@ -28,7 +29,6 @@ import org.eclipse.trace4cps.core.impl.PsopFragment; * All functions create new Psop instances! */ public class STLUtil { - private STLUtil() { } @@ -47,8 +47,8 @@ public class STLUtil { r.add(phi); } if (phi instanceof StlBinBool) { - getFormulas(((StlBinBool) phi).getLeft(), r); - getFormulas(((StlBinBool) phi).getRight(), r); + getFormulas(((StlBinBool)phi).getLeft(), r); + getFormulas(((StlBinBool)phi).getRight(), r); } else if (phi instanceof StlEq) { // } else if (phi instanceof StlGeq) { @@ -56,16 +56,16 @@ public class STLUtil { } else if (phi instanceof StlLeq) { // } else if (phi instanceof StlNeg) { - getFormulas(((StlNeg) phi).getFormula(), r); + getFormulas(((StlNeg)phi).getFormula(), r); } else if (phi instanceof StlUntil) { - getFormulas(((StlUntil) phi).getLeft(), r); - getFormulas(((StlUntil) phi).getRight(), r); + getFormulas(((StlUntil)phi).getLeft(), r); + getFormulas(((StlUntil)phi).getRight(), r); } } public static IPsop signal_greaterEqual(IPsop f, double c) { Psop r = new Psop(); - for (IPsopFragment frag : f.getFragments()) { + for (IPsopFragment frag: f.getFragments()) { r.add(new PsopFragment(frag.getC().doubleValue() - c, frag.getB(), frag.getA(), frag.dom())); } return r; @@ -73,7 +73,7 @@ public class STLUtil { public static IPsop signal_lessEqual(IPsop f, double c) { Psop r = new Psop(); - for (IPsopFragment frag : f.getFragments()) { + for (IPsopFragment frag: f.getFragments()) { r.add(new PsopFragment(c - frag.getC().doubleValue(), -frag.getB().doubleValue(), -frag.getA().doubleValue(), frag.dom())); } @@ -88,9 +88,9 @@ public class STLUtil { public static Psop signalNegate(IPsop f) { Psop r = new Psop(); - for (IPsopFragment frag : f.getFragments()) { - r.add(new PsopFragment(-frag.getC().doubleValue(), -frag.getB().doubleValue(), - -frag.getA().doubleValue(), frag.dom())); + for (IPsopFragment frag: f.getFragments()) { + r.add(new PsopFragment(-frag.getC().doubleValue(), -frag.getB().doubleValue(), -frag.getA().doubleValue(), + frag.dom())); } return r; } @@ -143,14 +143,16 @@ public class STLUtil { } } - private static void splitSingleIntersection(Psop r, double tSplit, IPsopFragment frag1, - IPsopFragment frag2, boolean applyMin) { + private static void splitSingleIntersection(Psop r, double tSplit, IPsopFragment frag1, IPsopFragment frag2, + boolean applyMin) + { if (tSplit == frag1.dom().lb().doubleValue()) { // special case for when the intersect point coincides with a domain boundary double size = frag1.dom().ub().doubleValue() - frag1.dom().lb().doubleValue(); double tHalfway = frag1.dom().lb().doubleValue() + (0.5 * size); if ((PsopHelper.valueAt(frag1, tHalfway).doubleValue() < PsopHelper.valueAt(frag2, tHalfway) - .doubleValue()) == applyMin) { + .doubleValue()) == applyMin) + { r.add(PsopHelper.copy(frag1)); } else { r.add(PsopHelper.copy(frag2)); @@ -166,7 +168,8 @@ public class STLUtil { } private static void splitDoubleIntersection(Psop r, double tSplit1, double tSplit2, IPsopFragment frag1, - IPsopFragment frag2, boolean applyMin) { + IPsopFragment frag2, boolean applyMin) + { if (tSplit1 == frag1.dom().lb().doubleValue()) { splitSingleIntersection(r, tSplit2, frag1, frag2, applyMin); return; @@ -223,7 +226,7 @@ public class STLUtil { f = PsopHelper.copy(f); // overwrite with a copy, because monotonization changes the psop List monoseg = PsopHelper.createMonotonicSegmentation(f); - for (ShapeSegment seg : monoseg) { + for (ShapeSegment seg: monoseg) { double t0 = f.getFragments().get(seg.getBeginFragment()).dom().lb().doubleValue(); double t1 = f.getFragments().get(seg.getEndFragment()).dom().ub().doubleValue(); double valt0 = f.getFragments().get(seg.getBeginFragment()).getC().doubleValue(); @@ -252,8 +255,7 @@ public class STLUtil { } /** - * Shifts the fragments from src that are specified in the segment b to the left and adds the result to - * dst. + * Shifts the fragments from src that are specified in the segment b to the left and adds the result to dst. */ private static void shiftLeft(ShapeSegment seg, IPsop src, Psop dst, double b) { for (int i = seg.getBeginFragment(); i <= seg.getEndFragment(); i++) { @@ -266,8 +268,7 @@ public class STLUtil { double lb = frag.dom().lb().doubleValue() - b; double ub = frag.dom().ub().doubleValue() - b; if (lb < ub) { // lb can get equal to ub due to rounding in floating point arithmetic - PsopFragment shifted = - new PsopFragment(frag.getC(), frag.getB(), frag.getA(), new Interval(lb, ub)); + PsopFragment shifted = new PsopFragment(frag.getC(), frag.getB(), frag.getA(), new Interval(lb, ub)); dst.add(shifted); } } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlBinBool.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlBinBool.java index 78f6aaf683de9c79bb9450945eb0519d0f7ad0af..3f079ef513c73c0485523411bf57cf60b2c897cf 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlBinBool.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlBinBool.java @@ -7,10 +7,10 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.stl.impl; import java.util.Arrays; -import java.util.Collections; import java.util.List; import org.eclipse.trace4cps.analysis.mtl.MtlFormula; @@ -18,10 +18,9 @@ import org.eclipse.trace4cps.analysis.stl.StlFormula; import org.eclipse.trace4cps.core.IPsop; public class StlBinBool extends AbstractStlFormula { - public enum BinOp { AND, OR, IMPLY - }; + } private final StlFormula left; @@ -43,14 +42,14 @@ public class StlBinBool extends AbstractStlFormula { @Override protected IPsop computeSignal() { switch (bop) { - case AND: - return STLUtil.signalAnd(left.getSignal(), right.getSignal()); - case OR: - return STLUtil.signalOr(left.getSignal(), right.getSignal()); - case IMPLY: - return STLUtil.signalImply(left.getSignal(), right.getSignal()); - default: - throw new IllegalStateException(); + case AND: + return STLUtil.signalAnd(left.getSignal(), right.getSignal()); + case OR: + return STLUtil.signalOr(left.getSignal(), right.getSignal()); + case IMPLY: + return STLUtil.signalImply(left.getSignal(), right.getSignal()); + default: + throw new IllegalStateException(); } } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlEq.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlEq.java index a885a11d2d4c234502f886a603d18c5fbb09933d..d2a807e4e3c6ee4b3034885fb2289431bf085e1a 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlEq.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlEq.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.stl.impl; import java.util.Collections; @@ -16,7 +17,6 @@ import org.eclipse.trace4cps.analysis.mtl.MtlFormula; import org.eclipse.trace4cps.core.IPsop; public class StlEq extends AbstractStlFormula { - private final IPsop f; private final double c; diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlGeq.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlGeq.java index b4773b8831c878833ca622c4fcc1b81a65ee6577..e4688cda59a95f82cbabb52b95e75603b777549d 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlGeq.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlGeq.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.stl.impl; import java.util.Collections; @@ -16,7 +17,6 @@ import org.eclipse.trace4cps.analysis.mtl.MtlFormula; import org.eclipse.trace4cps.core.IPsop; public class StlGeq extends AbstractStlFormula { - private final IPsop f; private final double c; diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlLeq.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlLeq.java index 978b7b01a9e1342e7e7cb29c0747b08ae9bdd941..5be0db80ec0591480419a3a7add6cbe1e7cb6fdf 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlLeq.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlLeq.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.stl.impl; import java.util.Collections; @@ -16,7 +17,6 @@ import org.eclipse.trace4cps.analysis.mtl.MtlFormula; import org.eclipse.trace4cps.core.IPsop; public class StlLeq extends AbstractStlFormula { - private final IPsop f; private final double c; diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlNeg.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlNeg.java index 0e53654b15e65715dbcc61a3553e335a5f16c8b4..6faafcfb641244229c12bbf838f7f9ae71ebc7e7 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlNeg.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlNeg.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.stl.impl; import java.util.Arrays; @@ -17,7 +18,6 @@ import org.eclipse.trace4cps.analysis.stl.StlFormula; import org.eclipse.trace4cps.core.IPsop; public class StlNeg extends AbstractStlFormula { - private final StlFormula f; public StlNeg(StlFormula f) { diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlTrue.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlTrue.java index 9bb6c73ac72b95ad1227542f337e0a73702f7b9b..9ecb65d1e2a8f27cb8ec888c889e01efe24c9f7e 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlTrue.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlTrue.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.stl.impl; import java.util.Collections; @@ -19,7 +20,6 @@ import org.eclipse.trace4cps.core.impl.Psop; import org.eclipse.trace4cps.core.impl.PsopFragment; public class StlTrue extends AbstractStlFormula { - @Override protected IPsop computeSignal() { Psop signal = new Psop(); diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlUntil.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlUntil.java index 5f8c323bd4cc8a00860e3fe28727e237bf884e03..e3d9056d0df72841c07534a85b86e72943ee73b4 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlUntil.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/stl/impl/StlUntil.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.stl.impl; import java.util.Arrays; @@ -17,7 +18,6 @@ import org.eclipse.trace4cps.analysis.stl.StlFormula; import org.eclipse.trace4cps.core.IPsop; public class StlUntil extends AbstractStlFormula { - private final StlFormula f1; private final StlFormula f2; diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/timing/NormalStatistics.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/timing/NormalStatistics.java index dd7184d51152a49f36a4492195da4041bbdd0fbc..fe0fa1730bf17fdec4351f30034caa17fbd8412b 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/timing/NormalStatistics.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/timing/NormalStatistics.java @@ -7,12 +7,12 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.timing; import java.util.List; public class NormalStatistics { - private final double mean; private final double stddev; @@ -33,7 +33,6 @@ public class NormalStatistics { } stddev = Math.sqrt(powSum / timings.size()); - } public double getMean() { diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/timing/StatisticsManager.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/timing/StatisticsManager.java index 4dd32eeb02a75b7c8ef4a35e1907c6cc88fed0ca..d76ca44d69221fe0ebda53b44b5ee9a52aea0503 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/timing/StatisticsManager.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/timing/StatisticsManager.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.timing; import java.math.BigDecimal; @@ -15,7 +16,6 @@ import java.util.List; import java.util.concurrent.TimeUnit; public class StatisticsManager { - private TimeUnit timeUnit; private final List samples = new ArrayList<>(); @@ -45,8 +45,7 @@ public class StatisticsManager { } /** - * Tries to get all samples to the format with at least 1 digit and at most 3 digits before the decimal - * separator. + * Tries to get all samples to the format with at least 1 digit and at most 3 digits before the decimal separator. */ public void autoScale() { if (getNumSamples() <= 0) { @@ -87,28 +86,29 @@ public class StatisticsManager { */ private boolean scaleUp() { switch (timeUnit) { - case NANOSECONDS: - scaleSamples(1000, false); - timeUnit = TimeUnit.MICROSECONDS; - return true; - case MICROSECONDS: - scaleSamples(1000, false); - timeUnit = TimeUnit.MILLISECONDS; - return true; - case MILLISECONDS: - scaleSamples(1000, false); - timeUnit = TimeUnit.SECONDS; - return true; - case SECONDS: - scaleSamples(60, false); - timeUnit = TimeUnit.MINUTES; - return true; - case MINUTES: - scaleSamples(60, false); - timeUnit = TimeUnit.HOURS; - return true; + case NANOSECONDS: + scaleSamples(1000, false); + timeUnit = TimeUnit.MICROSECONDS; + return true; + case MICROSECONDS: + scaleSamples(1000, false); + timeUnit = TimeUnit.MILLISECONDS; + return true; + case MILLISECONDS: + scaleSamples(1000, false); + timeUnit = TimeUnit.SECONDS; + return true; + case SECONDS: + scaleSamples(60, false); + timeUnit = TimeUnit.MINUTES; + return true; + case MINUTES: + scaleSamples(60, false); + timeUnit = TimeUnit.HOURS; + return true; + default: + return false; } - return false; } /** @@ -116,36 +116,37 @@ public class StatisticsManager { */ private boolean scaleDown() { switch (timeUnit) { - case MICROSECONDS: - scaleSamples(1000, true); - timeUnit = TimeUnit.NANOSECONDS; - return true; - case MILLISECONDS: - scaleSamples(1000, true); - timeUnit = TimeUnit.MICROSECONDS; - return true; - case SECONDS: - scaleSamples(1000, true); - timeUnit = TimeUnit.MILLISECONDS; - return true; - case MINUTES: - scaleSamples(60, true); - timeUnit = TimeUnit.SECONDS; - return true; - case HOURS: - scaleSamples(60, true); - timeUnit = TimeUnit.MINUTES; - return true; + case MICROSECONDS: + scaleSamples(1000, true); + timeUnit = TimeUnit.NANOSECONDS; + return true; + case MILLISECONDS: + scaleSamples(1000, true); + timeUnit = TimeUnit.MICROSECONDS; + return true; + case SECONDS: + scaleSamples(1000, true); + timeUnit = TimeUnit.MILLISECONDS; + return true; + case MINUTES: + scaleSamples(60, true); + timeUnit = TimeUnit.SECONDS; + return true; + case HOURS: + scaleSamples(60, true); + timeUnit = TimeUnit.MINUTES; + return true; + default: + return false; } - return false; } private void scaleSamples(long f, boolean mult) { List newSamples = new ArrayList<>(); - for (double d : samples) { + for (double d: samples) { if (!mult) { - newSamples.add(BigDecimal.valueOf(d).divide(BigDecimal.valueOf(f), BigDecimal.ROUND_HALF_DOWN) - .doubleValue()); + newSamples.add( + BigDecimal.valueOf(d).divide(BigDecimal.valueOf(f), BigDecimal.ROUND_HALF_DOWN).doubleValue()); } else { newSamples.add(BigDecimal.valueOf(d).multiply(BigDecimal.valueOf(f)).doubleValue()); } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/timing/TimingAnalysis.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/timing/TimingAnalysis.java index 0e48f925b6fa8a04402a823bbd9bf4bf125b3212..4769c48be2ae66a0e842a964826548ad6fe34625 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/timing/TimingAnalysis.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/analysis/timing/TimingAnalysis.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.analysis.timing; import java.math.BigDecimal; @@ -21,21 +22,20 @@ import org.eclipse.trace4cps.core.ITrace; import org.eclipse.trace4cps.core.impl.TraceHelper; public class TimingAnalysis { - private TimingAnalysis() { } public static Map analyse(ITrace trace, Collection claimGroupingAttributes) { Map r = new HashMap<>(); Map> p = createPartition(trace, claimGroupingAttributes); - for (Map.Entry> e : p.entrySet()) { + for (Map.Entry> e: p.entrySet()) { String name = e.getKey(); StatisticsManager stat = new StatisticsManager(trace.getTimeUnit()); r.put(name, stat); List claims = e.getValue(); - for (IClaim c : claims) { + for (IClaim c: claims) { double t = BigDecimal.valueOf(c.getEndTime().doubleValue()) - .subtract(BigDecimal.valueOf(c.getStartTime().doubleValue())).doubleValue(); + .subtract(BigDecimal.valueOf(c.getStartTime().doubleValue())).doubleValue(); stat.addSample(t); } stat.autoScale(); @@ -43,10 +43,9 @@ public class TimingAnalysis { return r; } - private static Map> createPartition(ITrace trace, - Collection claimGroupingAttributes) { + private static Map> createPartition(ITrace trace, Collection claimGroupingAttributes) { Map> p = new HashMap<>(); - for (IClaim c : trace.getClaims()) { + for (IClaim c: trace.getClaims()) { String attVals = TraceHelper.getValues(c, claimGroupingAttributes, false); List cell = p.get(attVals); if (cell == null) { diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/ClaimEventType.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/ClaimEventType.java index 3e7c338b63d0bf537067a2fe6358eabb59222c5b..ab9fd0e0da69de2db7296f184806869f346621b7 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/ClaimEventType.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/ClaimEventType.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core; /** diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IAttributeAware.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IAttributeAware.java index 33b9dbaee91c99bd19401d34eff9bcd832f597c1..8c398ef772c729abe40cf17f06f4f339fcdd483f 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IAttributeAware.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IAttributeAware.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core; import java.util.Map; @@ -16,7 +17,6 @@ import java.util.Map; * attributes that can be read and written through this interface. */ public interface IAttributeAware { - /** * Gets the attribute value with the specific key value * @@ -34,12 +34,12 @@ public interface IAttributeAware { /** * Sets a new attribute value, or overwrites an existing one. - * + * * @param key the key * @param value the attribute value */ void setAttribute(String key, String value); - + /** * Removes all attributes. */ diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IAttributeFilter.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IAttributeFilter.java index 5a94983e25ebdc021d8a8187ee4598a80b234bf3..2edb886cbd7f641d81c047c4559d66e406742e66 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IAttributeFilter.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IAttributeFilter.java @@ -7,14 +7,14 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core; /** - * A generic filter interface to filter parts of the TRACE data model which are based on the - * {@link IAttributeAware} interface. + * A generic filter interface to filter parts of the TRACE data model which are based on the {@link IAttributeAware} + * interface. */ public interface IAttributeFilter { - /** * @param a the TRACE part to evaluate * @return whether to include the given TRACE part diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IClaim.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IClaim.java index 2c4d9a33b7467cd25c61c26f00bc76110579ba62..9486916fece8747457c832fa0cb56c1dd5bac887 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IClaim.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IClaim.java @@ -7,18 +7,17 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core; /** * One of the central types of the TRACE data model. *

    - * A {@link IClaim} models the start and end time of a claim on a certain amount of some {@link IResource}. - * Every {@link IClaim} instance is associated with two {@link IClaimEvent} instances: one for its start and - * one for its end. - *

    + * A {@link IClaim} models the start and end time of a claim on a certain amount of some {@link IResource}. Every + * {@link IClaim} instance is associated with two {@link IClaimEvent} instances: one for its start and one for its end. + *

    */ public interface IClaim extends IAttributeAware { - /** * @return the start time of the claim */ @@ -41,7 +40,7 @@ public interface IClaim extends IAttributeAware { /** * @return the offset of the claimed amount, only meaningful if the resource uses an offset: - * {@link IResource#useOffset()} + * {@link IResource#useOffset()} */ Number getOffset(); diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IClaimEvent.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IClaimEvent.java index 2641e34a3ccaffba2a02ce5aadc487c252a2abfb..3f8d9011f7894a5a4a2a0b2d752e186a42afe6ac 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IClaimEvent.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IClaimEvent.java @@ -7,16 +7,16 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core; /** - * An {@link IClaimEvent} is a special event that is associated with an {@link IClaim} instance. Each - * {@link IClaim} instance has exactly two {@link IClaimEvent} instances: one for its start and one for its - * end. The manipulation of the attributes is delegated to the parent {@link IClaim} instance. That thus means - * that the {@link IClaim} and its two {@link IClaimEvent} instances have exactly the same set of attributes. + * An {@link IClaimEvent} is a special event that is associated with an {@link IClaim} instance. Each {@link IClaim} + * instance has exactly two {@link IClaimEvent} instances: one for its start and one for its end. The manipulation of + * the attributes is delegated to the parent {@link IClaim} instance. That thus means that the {@link IClaim} and its + * two {@link IClaimEvent} instances have exactly the same set of attributes. */ public interface IClaimEvent extends IEvent { - /** * @return the type of this claim event */ diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IDependency.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IDependency.java index 31b025fdcc477a418ff885a7565530a092fcc46a..e2fec8aa68c813fa673a5f214687e521c8b1a33b 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IDependency.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IDependency.java @@ -7,13 +7,13 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core; /** * A dependency between two {@link IEvent} instances. The semantics of a dependency is user-defined. */ public interface IDependency extends IAttributeAware { - /** * @return the source event */ diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IEvent.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IEvent.java index 249481e0c354220ac460d497b871713e7cca5026..6eee4aab63cb2acad84d18db57fc29d43390d47a 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IEvent.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IEvent.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core; import org.eclipse.trace4cps.analysis.mtl.State; @@ -14,12 +15,11 @@ import org.eclipse.trace4cps.analysis.mtl.State; /** * One of the central types of the TRACE data model. *

    - * An {@link IEvent} has a timestamp (also see {@link ITrace}) and a number of attributes. Furthermore, an {@link IEvent} extends the - * {@link State} type, which enables temporal-logic checking on sequences of events. - *

    + * An {@link IEvent} has a timestamp (also see {@link ITrace}) and a number of attributes. Furthermore, an + * {@link IEvent} extends the {@link State} type, which enables temporal-logic checking on sequences of events. + *

    */ public interface IEvent extends State { - /** * @return the timestamp of the event */ diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IExtendableTrace.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IExtendableTrace.java index deccd25b80d21f2d289a8e8ee07a1d9dc6f604d4..6660fa9bc0db3f8c6053f67eccb10eae154d28c6 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IExtendableTrace.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IExtendableTrace.java @@ -7,12 +7,12 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core; import java.util.Collection; public interface IExtendableTrace { - void addSignal(IPsop p); void addDependencies(Collection dependencies); diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IFilteredTrace.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IFilteredTrace.java index 28be3a6d426857fddf78f7b83d183880a22efafd..aedb54c08ad2d75a3d6fa02fcddeb7c6ae455d37 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IFilteredTrace.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IFilteredTrace.java @@ -7,37 +7,34 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core; import org.eclipse.trace4cps.core.impl.ModifiableTrace; /** - * This type adds filtering methods to the {@link ITrace} interface. The default implementation - * {@link ModifiableTrace} can be wrapped around any {@link ITrace} instance. + * This type adds filtering methods to the {@link ITrace} interface. The default implementation {@link ModifiableTrace} + * can be wrapped around any {@link ITrace} instance. */ public interface IFilteredTrace extends ITrace { - /** - * Adds a filter for a specific part of an {@link ITrace}. The filter is added to the already existing - * filters. The conjunction of all {@link IAttributeFilter#include(IAttributeAware)} is taken for whether - * an element is included - *

    - * The result is not recalculated, because this can be a relatively expensive operation and more filters - * might be added. An explicit call to {@link #recalculate()} is needed for the new filters to take - * effect. - * + * Adds a filter for a specific part of an {@link ITrace}. The filter is added to the already existing filters. The + * conjunction of all {@link IAttributeFilter#include(IAttributeAware)} is taken for whether an element is included + *

    + * The result is not recalculated, because this can be a relatively expensive operation and more filters might be + * added. An explicit call to {@link #recalculate()} is needed for the new filters to take effect. + * * @param type the part of the trace to which the filter applies * @param filter a new filter element to add */ void addFilter(TracePart type, T filter); /** - * Adds a filter for a specific part of an {@link ITrace}. The filter is added to the already existing - * filters. The conjunction of all {@link IAttributeFilter#include(IAttributeAware)} is taken for whether - * an element is included - *

    + * Adds a filter for a specific part of an {@link ITrace}. The filter is added to the already existing filters. The + * conjunction of all {@link IAttributeFilter#include(IAttributeAware)} is taken for whether an element is included + *

    * The result is not recalculated. - * + * * @param type the part of the trace to which the filter applies * @param filter a new filter element to add */ @@ -50,7 +47,7 @@ public interface IFilteredTrace extends ITrace { /** * Clears the filters for the given parts of the trace. - * + * * @param type the type of filters to clear */ void clearFilter(TracePart type); diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IInterval.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IInterval.java index 747a6c762a476c2e0356cbb9d531a9ee1d3bb94d..0ee4ade67107b9b78b10a1377d4e2fe755ddf438 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IInterval.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IInterval.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core; /** @@ -15,7 +16,6 @@ package org.eclipse.trace4cps.core; * respectively. */ public interface IInterval { - /** * @return the lower bound of the interval */ diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IPsop.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IPsop.java index b2da70ac7819764b6ccf2964ccee8ce8f30b3d7d..2753c8faa6ab2911b3175328f827a5aee2a38916 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IPsop.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IPsop.java @@ -7,22 +7,24 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core; import java.util.List; +import org.eclipse.trace4cps.core.impl.Psop; + /** * One of the central types of the TRACE data model. - * + * *

    * A piecewise second-order polynomial, consisting of consecutive {@link IPsopFragment} instances. - *

    + *

    */ public interface IPsop extends IAttributeAware { - /** * The fragments are ordered by their time-domain, are consecutive, and have no overlap. - * + * * @return the fragments that define this {@link Psop} */ List getFragments(); diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IPsopFragment.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IPsopFragment.java index e49a580396334f8f1763dc67324b1fbfeba83082..0206484e85d5a8ebe7e0d385365713060c129d31 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IPsopFragment.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IPsopFragment.java @@ -7,15 +7,15 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core; /** - * Encodes a second-order polynomial {@code f(t)} on the time domain {@link #dom()}. The time domain is a - * left-closed, right-open interval: {@code [t0, t1)}. For all {@code t} in {@code dom}, we have + * Encodes a second-order polynomial {@code f(t)} on the time domain {@link #dom()}. The time domain is a left-closed, + * right-open interval: {@code [t0, t1)}. For all {@code t} in {@code dom}, we have * {@code f(t) = a*(t-t_0)^2 + b * (t - t_0) + c}. */ public interface IPsopFragment { - /** * @return the second-order coefficient */ diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IResource.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IResource.java index 866bb942c4ff2753c2988dd78eade2382c620c84..b25dda11868bab99108c45efedd0514dfee3d887 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IResource.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/IResource.java @@ -7,17 +7,17 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core; /** * One of the central types of the TRACE data model. *

    - * An {@link IResource} has a positive capacity and indicates whether claims on it use an offset or not. - * This offset can be used, for instance, to model memory fragmentation. - *

    + * An {@link IResource} has a positive capacity and indicates whether claims on it use an offset or not. This offset can + * be used, for instance, to model memory fragmentation. + *

    */ public interface IResource extends IAttributeAware { - /** * @return the capacity of the resource */ diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/ITrace.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/ITrace.java index 30328f1175486569467c326bdd9db6b685c5b2ad..b929d7d0c608f8269105ceca957458139902ab99 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/ITrace.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/ITrace.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core; import java.util.List; @@ -14,24 +15,23 @@ import java.util.concurrent.TimeUnit; /** * The central type of the TRACE data model. - * + * *

    - * Caveat: All computations in this library involving {@link Number} instances use - * {@link Number#doubleValue()} and double arithmetic. This may cause rounding effects. + * Caveat: All computations in this library involving {@link Number} instances use {@link Number#doubleValue()} + * and double arithmetic. This may cause rounding effects. *

    */ public interface ITrace extends IAttributeAware { - /** * @return the {@link TimeUnit} of the time stamps in this trace */ TimeUnit getTimeUnit(); /** - * Specifies the time offset for the time stamps in this trace. All methods in the API that return - * time stamps, return time stamps relative to this offset. Note that time stamp getters typically - * return a {@link Number} instance, thereby allowing an arbitrary precision. - * + * Specifies the time offset for the time stamps in this trace. All methods in the API that return time stamps, + * return time stamps relative to this offset. Note that time stamp getters typically return a {@link Number} + * instance, thereby allowing an arbitrary precision. + * * @return the time offset as number of milliseconds since the epoch */ Number getTimeOffset(); @@ -45,16 +45,16 @@ public interface ITrace extends IAttributeAware { /** * Gets the {@link IResource} instances used by the {@link IClaim} instances. - * + * * @return the {@link IResource} instances used by the {@link IClaim} instances */ List getResources(); /** - * Gets the {@link IEvent} instances, ordered ascending by their timestamp. This list includes the events - * that belong to start and end of {@link IClaim} instances, i.e., the events obtained via - * {@link IClaim#getStartEvent()} and {@link IClaim#getEndEvent()}. These "derived" events of the - * {@link IClaimEvent} type delegate the attribute manipulation to their {@link IClaim} instance. + * Gets the {@link IEvent} instances, ordered ascending by their timestamp. This list includes the events that + * belong to start and end of {@link IClaim} instances, i.e., the events obtained via {@link IClaim#getStartEvent()} + * and {@link IClaim#getEndEvent()}. These "derived" events of the {@link IClaimEvent} type delegate the attribute + * manipulation to their {@link IClaim} instance. * * @return the events */ diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/Shape.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/Shape.java index 060a42c301403cdad3b9ebe18bf97b399fa5974c..3d47a0f0bcc3fa832bf7c2215c1b554f77472fdf 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/Shape.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/Shape.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core; /** diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/TraceException.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/TraceException.java index f846e76571f34915944cb2993b0c2b457e416ae9..ca0c1197c49800e49f8baece96a35bfbe1ba3c9c 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/TraceException.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/TraceException.java @@ -7,13 +7,13 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core; /** * The top-level exception in the TRACE library. */ public class TraceException extends Exception { - private static final long serialVersionUID = 1L; public TraceException() { diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/TracePart.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/TracePart.java index 260da0f32a52385c948b8fff81ea39b20ce98898..99e5c350cd2f8147fc832e6129132e7e05c27b3b 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/TracePart.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/TracePart.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core; /** diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/AttributeAware.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/AttributeAware.java index a0861412dbaa66fd5f064e877ad5034b3bdc1997..d4a21a51a8237e7a9cc4271261b81ee665d7f6fd 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/AttributeAware.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/AttributeAware.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.impl; import java.util.Collections; @@ -16,11 +17,10 @@ import java.util.Map; import org.eclipse.trace4cps.core.IAttributeAware; /** - * Default implementation of the {@link IAttributeAware} type. This class can be subclassed to implement the - * various parts of the TRACE data model. + * Default implementation of the {@link IAttributeAware} type. This class can be subclassed to implement the various + * parts of the TRACE data model. */ public class AttributeAware implements IAttributeAware { - private final Map attributes = new HashMap<>(); /** @@ -57,14 +57,15 @@ public class AttributeAware implements IAttributeAware { /** * Replaces the existing attributes with a new set. - * + * * @param atts the new set of attributes to replace the ecisting ones */ public void setAttributes(Map atts) { attributes.clear(); if (atts != null) { - for (Map.Entry e : atts.entrySet()) + for (Map.Entry e: atts.entrySet()) { setAttribute(e.getKey(), e.getValue()); + } } } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Claim.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Claim.java index e81a0105be8e83f0690bf4f55cb66e6c3ef90431..a901accbdf09dc7b1a42cf593b1f26241760631b 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Claim.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Claim.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.impl; import java.util.Map; @@ -17,11 +18,10 @@ import org.eclipse.trace4cps.core.IClaimEvent; import org.eclipse.trace4cps.core.IResource; /** - * Default implementation of the {@link IClaim} type. The constructors create new instances for the start and - * end events. + * Default implementation of the {@link IClaim} type. The constructors create new instances for the start and end + * events. */ public class Claim extends AttributeAware implements IClaim { - private final Number startTime; private final Number endTime; @@ -48,15 +48,14 @@ public class Claim extends AttributeAware implements IClaim { this(t0, t1, r, offset, amount, null); } - public Claim(Number t0, Number t1, IResource r, Number offset, Number amount, - Map attMap) { + public Claim(Number t0, Number t1, IResource r, Number offset, Number amount, Map attMap) { this.startTime = t0; this.endTime = t1; this.resource = r; if ((r.useOffset() && Double.isNaN(offset.doubleValue())) - || (!r.useOffset() && !Double.isNaN(offset.doubleValue()))) { - throw new IllegalArgumentException( - "offset must be specified if and only if the resource uses an offset"); + || (!r.useOffset() && !Double.isNaN(offset.doubleValue()))) + { + throw new IllegalArgumentException("offset must be specified if and only if the resource uses an offset"); } this.offset = offset; this.amount = amount; @@ -129,7 +128,7 @@ public class Claim extends AttributeAware implements IClaim { */ @Override public String toString() { - return "Claim[" + startTime + "-" + endTime + ", amount=" + amount + ", offset=" + offset - + ", resoure=" + resource + ", attributes=" + getAttributes() + "]"; + return "Claim[" + startTime + "-" + endTime + ", amount=" + amount + ", offset=" + offset + ", resoure=" + + resource + ", attributes=" + getAttributes() + "]"; } } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/ClaimEvent.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/ClaimEvent.java index 268a0c1109cc3ffffb6ed1be0178669d1e35462a..1ac45dda5df1c4aaadbf2611fe258e90d2af1276 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/ClaimEvent.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/ClaimEvent.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.impl; import java.util.Map; @@ -20,7 +21,6 @@ import org.eclipse.trace4cps.core.IClaimEvent; * Default implementation of the {@link IClaimEvent}. */ public class ClaimEvent extends Event implements IClaimEvent { - private final IClaim claim; private final ClaimEventType type; @@ -46,7 +46,7 @@ public class ClaimEvent extends Event implements IClaimEvent { public ClaimEventType getType() { return type; } - + /** * {@inheritDoc} */ diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Dependency.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Dependency.java index d985970c824b5787fa38879064cb47120711c9a5..580319d438ee85e5a8aa96011f21c9337be64254 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Dependency.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Dependency.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.impl; import org.eclipse.trace4cps.core.IDependency; @@ -16,7 +17,6 @@ import org.eclipse.trace4cps.core.IEvent; * Default implementation of the {@link IDependency} type. */ public class Dependency extends AttributeAware implements IDependency { - private final IEvent src; private final IEvent dst; diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Event.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Event.java index c21f3cc802899f0b68b7ec6153eba134319515c4..59c27106cfd034c5784420cb4d7a5b2917846026 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Event.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Event.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.impl; import org.eclipse.trace4cps.analysis.mtl.AtomicProposition; @@ -16,7 +17,6 @@ import org.eclipse.trace4cps.core.IEvent; * Default implementation of the {@link IEvent} type. */ public class Event extends AttributeAware implements IEvent { - private Number timestamp; public Event(Number timestamp) { diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Interval.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Interval.java index d962033593470c751807c3ecbb3b8b711cf99cc1..3047a737ff84ba4142576ece75f723c566d45594 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Interval.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Interval.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.impl; import org.eclipse.trace4cps.core.IInterval; @@ -15,7 +16,6 @@ import org.eclipse.trace4cps.core.IInterval; * Default implementation of the {@link IInterval} type, immutable. */ public final class Interval implements IInterval { - private final Number lb; private final Number ub; @@ -26,7 +26,7 @@ public final class Interval implements IInterval { /** * Constructs a left-closed right-open interval - * + * * @param lb the lower bound * @param ub the upper bound */ @@ -104,8 +104,7 @@ public final class Interval implements IInterval { @Override public boolean isEmpty() { - return lb.doubleValue() > ub.doubleValue() - || (lb.doubleValue() == ub.doubleValue() && (openLb || openUb)); + return lb.doubleValue() > ub.doubleValue() || (lb.doubleValue() == ub.doubleValue() && (openLb || openUb)); } @Override @@ -140,7 +139,7 @@ public final class Interval implements IInterval { ub = i2.ub; openUb = i2.openUb; } - return new Interval(lb, openLb, ub, openUb); + return new Interval(lb, openLb, ub, openUb); } @Override @@ -156,27 +155,36 @@ public final class Interval implements IInterval { @Override public boolean equals(Object obj) { - if (this == obj) + if (this == obj) { return true; - if (obj == null) + } + if (obj == null) { return false; - if (getClass() != obj.getClass()) + } + if (getClass() != obj.getClass()) { return false; - Interval other = (Interval) obj; + } + Interval other = (Interval)obj; if (lb == null) { - if (other.lb != null) + if (other.lb != null) { return false; - } else if (!lb.equals(other.lb)) + } + } else if (!lb.equals(other.lb)) { return false; - if (openLb != other.openLb) + } + if (openLb != other.openLb) { return false; - if (openUb != other.openUb) + } + if (openUb != other.openUb) { return false; + } if (ub == null) { - if (other.ub != null) + if (other.ub != null) { return false; - } else if (!ub.equals(other.ub)) + } + } else if (!ub.equals(other.ub)) { return false; + } return true; } } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/ModifiableTrace.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/ModifiableTrace.java index 027ba4d00a995448b5c1aa233415270a19e6e765..11d76e189b7827b7cfa6f60bae4eabc0eb8c462b 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/ModifiableTrace.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/ModifiableTrace.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.impl; import java.util.ArrayList; @@ -34,7 +35,6 @@ import org.eclipse.trace4cps.core.TracePart; * Default implementation of the {@link IFilteredTrace} and {@link IExtendableTrace} types. */ public class ModifiableTrace implements IFilteredTrace, IExtendableTrace { - private final List claimFilters = new ArrayList<>(); private final List resourceFilters = new ArrayList<>(); @@ -68,7 +68,6 @@ public class ModifiableTrace implements IFilteredTrace, IExtendableTrace { private List extResources = new ArrayList<>(); private static final Comparator EVENT_COMP = new Comparator() { - @Override public int compare(IEvent e1, IEvent e2) { return Double.compare(e1.getTimestamp().doubleValue(), e2.getTimestamp().doubleValue()); @@ -77,7 +76,7 @@ public class ModifiableTrace implements IFilteredTrace, IExtendableTrace { /** * Wraps the given trace with this filtering facade. - * + * * @param trace the wrapped trace */ public ModifiableTrace(ITrace trace) { @@ -118,7 +117,7 @@ public class ModifiableTrace implements IFilteredTrace, IExtendableTrace { @Override public void addClaims(Collection claims) { extClaims.addAll(claims); - for (IClaim claim : claims) { + for (IClaim claim: claims) { extEvents.add(claim.getStartEvent()); extEvents.add(claim.getEndEvent()); if (!extResources.contains(claim.getResource())) { @@ -134,18 +133,18 @@ public class ModifiableTrace implements IFilteredTrace, IExtendableTrace { @Override public boolean hasExtension(TracePart part) { switch (part) { - case ALL: - return !extSignals.isEmpty() || !extDependencies.isEmpty() || !extEvents.isEmpty(); - case SIGNAL: - return !extSignals.isEmpty(); - case DEPENDENCY: - return !extDependencies.isEmpty(); - case EVENT: - return !extEvents.isEmpty(); - case CLAIM: - return !extClaims.isEmpty(); - default: - return false; + case ALL: + return !extSignals.isEmpty() || !extDependencies.isEmpty() || !extEvents.isEmpty(); + case SIGNAL: + return !extSignals.isEmpty(); + case DEPENDENCY: + return !extDependencies.isEmpty(); + case EVENT: + return !extEvents.isEmpty(); + case CLAIM: + return !extClaims.isEmpty(); + default: + return false; } } @@ -155,38 +154,38 @@ public class ModifiableTrace implements IFilteredTrace, IExtendableTrace { @Override public void clearExtension(TracePart part) { switch (part) { - case ALL: - extSignals.clear(); - extDependencies.clear(); - extEvents.clear(); - extClaims.clear(); - extResources.clear(); - break; - case SIGNAL: - extSignals.clear(); - break; - case DEPENDENCY: - extDependencies.clear(); - break; - case EVENT: - // do not remove the claim events from the extClaims - extEvents.clear(); - for (IClaim c : extClaims) { - extEvents.add(c.getStartEvent()); - extEvents.add(c.getEndEvent()); - } - Collections.sort(extEvents, EVENT_COMP); - break; - case CLAIM: - extResources.clear(); - for (IClaim c : extClaims) { - extEvents.remove(c.getStartEvent()); - extEvents.remove(c.getEndEvent()); - } - extClaims.clear(); - break; - default: - throw new IllegalStateException(); + case ALL: + extSignals.clear(); + extDependencies.clear(); + extEvents.clear(); + extClaims.clear(); + extResources.clear(); + break; + case SIGNAL: + extSignals.clear(); + break; + case DEPENDENCY: + extDependencies.clear(); + break; + case EVENT: + // do not remove the claim events from the extClaims + extEvents.clear(); + for (IClaim c: extClaims) { + extEvents.add(c.getStartEvent()); + extEvents.add(c.getEndEvent()); + } + Collections.sort(extEvents, EVENT_COMP); + break; + case CLAIM: + extResources.clear(); + for (IClaim c: extClaims) { + extEvents.remove(c.getStartEvent()); + extEvents.remove(c.getEndEvent()); + } + extClaims.clear(); + break; + default: + throw new IllegalStateException(); } recalculate(); } @@ -210,23 +209,23 @@ public class ModifiableTrace implements IFilteredTrace, IExtendableTrace { private void clearInt(TracePart type) { switch (type) { - case CLAIM: - claimFilters.clear(); - break; - case EVENT: - eventFilters.clear(); - break; - case RESOURCE: - resourceFilters.clear(); - break; - case DEPENDENCY: - dependencyFilters.clear(); - break; - case SIGNAL: - signalFilters.clear(); - break; - case ALL: - throw new IllegalStateException("should not be called"); + case CLAIM: + claimFilters.clear(); + break; + case EVENT: + eventFilters.clear(); + break; + case RESOURCE: + resourceFilters.clear(); + break; + case DEPENDENCY: + dependencyFilters.clear(); + break; + case SIGNAL: + signalFilters.clear(); + break; + case ALL: + throw new IllegalStateException("should not be called"); } } @@ -248,28 +247,28 @@ public class ModifiableTrace implements IFilteredTrace, IExtendableTrace { private void addFilter(TracePart type, boolean recalc, IAttributeFilter filter) { switch (type) { - case CLAIM: - addFilter(claimFilters, filter); - break; - case RESOURCE: - addFilter(resourceFilters, filter); - break; - case EVENT: - addFilter(eventFilters, filter); - break; - case SIGNAL: - addFilter(signalFilters, filter); - break; - case DEPENDENCY: - addFilter(dependencyFilters, filter); - break; - case ALL: - addFilter(claimFilters, filter); - addFilter(resourceFilters, filter); - addFilter(eventFilters, filter); - addFilter(signalFilters, filter); - addFilter(dependencyFilters, filter); - break; + case CLAIM: + addFilter(claimFilters, filter); + break; + case RESOURCE: + addFilter(resourceFilters, filter); + break; + case EVENT: + addFilter(eventFilters, filter); + break; + case SIGNAL: + addFilter(signalFilters, filter); + break; + case DEPENDENCY: + addFilter(dependencyFilters, filter); + break; + case ALL: + addFilter(claimFilters, filter); + addFilter(resourceFilters, filter); + addFilter(eventFilters, filter); + addFilter(signalFilters, filter); + addFilter(dependencyFilters, filter); + break; } if (recalc) { recalculate(); @@ -311,9 +310,9 @@ public class ModifiableTrace implements IFilteredTrace, IExtendableTrace { dependencies.addAll(extDependencies); // Then filter if needed if (!dependencyFilters.isEmpty() || !eventFilters.isEmpty() || !claimFilters.isEmpty() - || !resourceFilters.isEmpty()) { + || !resourceFilters.isEmpty()) + { dependencies = recalc(dependencies, dependencyFilters, new InclusionConstraint() { - @Override boolean include(IDependency a) { return events.contains(a.getSrc()) && events.contains(a.getDst()); @@ -330,11 +329,10 @@ public class ModifiableTrace implements IFilteredTrace, IExtendableTrace { // Filter if needed if (!eventFilters.isEmpty() || !claimFilters.isEmpty() || !resourceFilters.isEmpty()) { events = recalc(events, eventFilters, new InclusionConstraint() { - @Override boolean include(IEvent a) { if (a instanceof IClaimEvent) { - return claims.contains(((IClaimEvent) a).getClaim()); + return claims.contains(((IClaimEvent)a).getClaim()); } return true; } @@ -349,10 +347,10 @@ public class ModifiableTrace implements IFilteredTrace, IExtendableTrace { // Filter if needed if (!claimFilters.isEmpty() || !resourceFilters.isEmpty()) { claims = recalc(claims, claimFilters, new InclusionConstraint() { - + @Override boolean include(IClaim c) { return resources.contains(c.getResource()); - }; + } }); } } @@ -368,14 +366,14 @@ public class ModifiableTrace implements IFilteredTrace, IExtendableTrace { } private abstract class InclusionConstraint { - abstract boolean include(T a); } private List recalc(List origList, List filters, - InclusionConstraint constraint) { + InclusionConstraint constraint) + { List filteredList = new ArrayList<>(); - for (T r : origList) { + for (T r: origList) { if (matches(r, filters) && (constraint == null || constraint.include(r))) { filteredList.add(r); } @@ -390,7 +388,7 @@ public class ModifiableTrace implements IFilteredTrace, IExtendableTrace { if (filters.isEmpty()) { return true; } - for (IAttributeFilter f : filters) { + for (IAttributeFilter f: filters) { if (!f.include(a)) { return false; } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Psop.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Psop.java index c92a0a891ce41028180d9f677d374e3ed3db4225..8b2210ba3681236dbb849b83f103d5044d2f230e 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Psop.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Psop.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.impl; import java.util.ArrayList; @@ -20,7 +21,6 @@ import org.eclipse.trace4cps.core.IPsopFragment; * Default implementation of the {@link IPsop} type. */ public final class Psop extends AttributeAware implements IPsop { - private final List fragments = new ArrayList<>(); /** @@ -52,9 +52,9 @@ public final class Psop extends AttributeAware implements IPsop { IPsopFragment last = fragments.get(fragments.size() - 1); check(last, f); // merge fragments if equal constant values - if (f.getA().doubleValue() == 0d && f.getB().doubleValue() == 0d - && last.getA().doubleValue() == 0d && last.getB().doubleValue() == 0d - && f.getC().doubleValue() == last.getC().doubleValue()) { + if (f.getA().doubleValue() == 0d && f.getB().doubleValue() == 0d && last.getA().doubleValue() == 0d + && last.getB().doubleValue() == 0d && f.getC().doubleValue() == last.getC().doubleValue()) + { fragments.remove(fragments.size() - 1); fragments.add(new PsopFragment(f.getC(), f.getB(), f.getA(), new Interval(last.dom().lb(), false, f.dom().ub(), true))); @@ -90,8 +90,8 @@ public final class Psop extends AttributeAware implements IPsop { private boolean mergeable(IPsopFragment f0, IPsopFragment f1) { double x = f0.dom().ub().doubleValue(); // equal to f1.dom().lb() return f0.getA().doubleValue() == f1.getA().doubleValue() - && Math.abs(PsopHelper.valueAt(f0, x).doubleValue() - f1.getC().doubleValue()) < 1e-12 && Math - .abs(PsopHelper.valueDerivativeAt(f0, x).doubleValue() - f1.getB().doubleValue()) < 1e-12; + && Math.abs(PsopHelper.valueAt(f0, x).doubleValue() - f1.getC().doubleValue()) < 1e-12 + && Math.abs(PsopHelper.valueDerivativeAt(f0, x).doubleValue() - f1.getB().doubleValue()) < 1e-12; } private void check(IPsopFragment f1, IPsopFragment f2) { @@ -104,7 +104,7 @@ public final class Psop extends AttributeAware implements IPsop { public String toString() { StringBuilder b = new StringBuilder("Psop[attributes=" + getAttributes()); b.append(", fragments:\n"); - for (IPsopFragment f : fragments) { + for (IPsopFragment f: fragments) { b.append("\t").append(f.toString()).append("\n"); } b.append("]\n"); diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/PsopFragment.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/PsopFragment.java index b81bdda674026c0bce2e26cc76cabb5ce1cd3c95..646cd66c449d1443d7f789f04fee107ad13948c0 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/PsopFragment.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/PsopFragment.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.impl; import org.eclipse.trace4cps.core.IInterval; @@ -17,7 +18,6 @@ import org.eclipse.trace4cps.core.Shape; * Default implementation of the {@link IPsopFragment} type, immutable. */ public final class PsopFragment implements IPsopFragment { - private final Number c; private final Number b; @@ -139,7 +139,8 @@ public final class PsopFragment implements IPsopFragment { // Compute the parameters of the quadratic equation a*x^2 + b*x + c double tTop = -b.doubleValue() / (2 * a.doubleValue()); if (dom.lb().doubleValue() < dom.lb().doubleValue() + tTop - && dom.lb().doubleValue() + tTop < dom.ub().doubleValue()) { + && dom.lb().doubleValue() + tTop < dom.ub().doubleValue()) + { return compute2ndOrderShapeTopInSegment(tTop); } else { // check whether increasing or decreasing diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Resource.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Resource.java index 558f6c4a942143f8336bc0b66fe8614655a0481f..eefe1d7d8b5ce59523e88254213afcc42cffb928 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Resource.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Resource.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.impl; import org.eclipse.trace4cps.core.IResource; @@ -15,7 +16,6 @@ import org.eclipse.trace4cps.core.IResource; * Default implementation of the {@link IResource} type. */ public class Resource extends AttributeAware implements IResource { - private Number capacity; private final boolean useOffset; @@ -53,7 +53,6 @@ public class Resource extends AttributeAware implements IResource { */ @Override public String toString() { - return "Resource[capacity=" + capacity + ", usesOffset=" + useOffset + ", attributes=" - + getAttributes() + "]"; + return "Resource[capacity=" + capacity + ", usesOffset=" + useOffset + ", attributes=" + getAttributes() + "]"; } } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Trace.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Trace.java index 1c6eb2f129dd97200a5d8adc4f77ad202f474c58..3cc9f299d947a9d045dba8a97bc5c8e1aee41b92 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Trace.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/Trace.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.impl; import java.util.ArrayList; @@ -29,7 +30,6 @@ import org.eclipse.trace4cps.core.ITrace; * Default implementation of the {@link ITrace} type. */ public class Trace extends AttributeAware implements ITrace { - private List claims = new ArrayList<>(); private Set resources = new HashSet<>(); @@ -42,7 +42,7 @@ public class Trace extends AttributeAware implements ITrace { private TimeUnit traceTimeUnit = TimeUnit.SECONDS; - private Number timeOffset = 0l; + private Number timeOffset = 0L; private boolean sorted = false; @@ -109,7 +109,7 @@ public class Trace extends AttributeAware implements ITrace { public List getSignals() { return Collections.unmodifiableList(signals); } - + public void setTimeUnit(TimeUnit tu) { this.traceTimeUnit = tu; } @@ -128,8 +128,7 @@ public class Trace extends AttributeAware implements ITrace { public void add(IEvent event) { if (event instanceof IClaimEvent) { - throw new IllegalArgumentException( - "IClaimEvent instances are added automatically via add(IClaim)"); + throw new IllegalArgumentException("IClaimEvent instances are added automatically via add(IClaim)"); } events.add(event); sorted = false; @@ -146,16 +145,16 @@ public class Trace extends AttributeAware implements ITrace { public void sortAll() { if (!sorted) { Collections.sort(events, new Comparator() { - + @Override public int compare(IEvent o1, IEvent o2) { return Double.compare(o1.getTimestamp().doubleValue(), o2.getTimestamp().doubleValue()); - }; + } }); Collections.sort(claims, new Comparator() { - + @Override public int compare(IClaim o1, IClaim o2) { return Double.compare(o1.getStartTime().doubleValue(), o2.getStartTime().doubleValue()); - }; + } }); sorted = true; } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/TraceHelper.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/TraceHelper.java index 2137b7df497f28ddb5fcde126a8a0064d3c24f00..0f81588cfb903229d4174dc50e75d35d641eeccd 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/TraceHelper.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/impl/TraceHelper.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.impl; import java.util.ArrayList; @@ -34,7 +35,6 @@ import org.eclipse.trace4cps.core.ITrace; * A utility class for doing all kinds of things with traces. */ public class TraceHelper { - private TraceHelper() { } @@ -54,9 +54,8 @@ public class TraceHelper { return result; } - private static void getAttributeValues(Collection list, String att, - Set result) { - for (IAttributeAware a : list) { + private static void getAttributeValues(Collection list, String att, Set result) { + for (IAttributeAware a: list) { String val = a.getAttributeValue(att); if (val != null) { result.add(val); @@ -81,13 +80,13 @@ public class TraceHelper { } private static void getAttributeNames(Collection list, Set result) { - for (IAttributeAware a : list) { + for (IAttributeAware a: list) { result.addAll(a.getAttributes().keySet()); } } public static boolean hasNonClaimEvents(ITrace trace) { - for (IEvent e : trace.getEvents()) { + for (IEvent e: trace.getEvents()) { if (!(e instanceof IClaimEvent)) { return true; } @@ -97,7 +96,7 @@ public class TraceHelper { public static List getEvents(ITrace trace, boolean includeClaimEvents) { List r = new ArrayList<>(); - for (IEvent e : trace.getEvents()) { + for (IEvent e: trace.getEvents()) { if (!(e instanceof IClaimEvent) || includeClaimEvents) { r.add(e); } @@ -108,7 +107,7 @@ public class TraceHelper { public static List getClaimsAndEvents(ITrace trace, boolean includeClaimEvents) { List r = new ArrayList<>(); r.addAll(trace.getClaims()); - for (IEvent e : trace.getEvents()) { + for (IEvent e: trace.getEvents()) { if (!(e instanceof IClaimEvent) || includeClaimEvents) { r.add(e); } @@ -129,15 +128,15 @@ public class TraceHelper { public static IInterval getDomain(ITrace trace) { double min = Double.POSITIVE_INFINITY; double max = Double.NEGATIVE_INFINITY; - for (IClaim c : trace.getClaims()) { + for (IClaim c: trace.getClaims()) { min = Math.min(min, c.getStartTime().doubleValue()); max = Math.max(max, c.getEndTime().doubleValue()); } - for (IEvent e : trace.getEvents()) { + for (IEvent e: trace.getEvents()) { min = Math.min(min, e.getTimestamp().doubleValue()); max = Math.max(max, e.getTimestamp().doubleValue()); } - for (IPsop p : trace.getSignals()) { + for (IPsop p: trace.getSignals()) { min = Math.min(min, PsopHelper.getDomainLowerBound(p).doubleValue()); max = Math.max(max, PsopHelper.getDomainUpperBound(p).doubleValue()); } @@ -163,7 +162,7 @@ public class TraceHelper { * @return whether every filter entry is present in the attributes */ public static boolean matches(Map filter, Map attributes) { - for (Map.Entry e : filter.entrySet()) { + for (Map.Entry e: filter.entrySet()) { String attVal = attributes.get(e.getKey()); if (!e.getValue().equals(attVal)) { return false; @@ -174,7 +173,7 @@ public class TraceHelper { public static List filter(Collection l, Map filter) { List result = new ArrayList<>(); - for (T aa : l) { + for (T aa: l) { if (matches(filter, aa.getAttributes())) { result.add(aa); } @@ -193,7 +192,7 @@ public class TraceHelper { StringBuilder b = new StringBuilder(); getValues(b, event, includeAttNames); if (event instanceof IClaimEvent) { - IClaimEvent claimEvent = (IClaimEvent) event; + IClaimEvent claimEvent = (IClaimEvent)event; b.append(",res={"); IResource resource = claimEvent.getClaim().getResource(); getValues(b, resource, includeAttNames); @@ -228,7 +227,8 @@ public class TraceHelper { } private static void getValues(StringBuilder b, IAttributeAware aa, Collection atts, - boolean includeAttName) { + boolean includeAttName) + { List keys = new ArrayList<>(); if (atts != null && atts.size() > 0) { keys.addAll(atts); diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/DependencyType.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/DependencyType.java index 007f5eafaf7fe07176f59ba62ebcd36bba4de5f5..af22f3a204c3166684411aba4072504201807ded 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/DependencyType.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/DependencyType.java @@ -7,13 +7,13 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.io; /** * This type enumerates the possible dependencies between claims and events that can be specified. */ public enum DependencyType { - CLAIM_START_CLAIM_START(0), CLAIM_START_CLAIM_END(1), CLAIM_END_CLAIM_START(2), @@ -31,7 +31,7 @@ public enum DependencyType { } public static DependencyType typeFor(int v) { - for (DependencyType t : DependencyType.values()) { + for (DependencyType t: DependencyType.values()) { if (t.value == v) { return t; } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/ParseException.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/ParseException.java index 40de5c43d3fc7fce7ef6265dd0d39846c0edad08..c38954be291e71d59b8a53282f28275e1addd14f 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/ParseException.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/ParseException.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.io; import org.eclipse.trace4cps.core.TraceException; @@ -15,7 +16,6 @@ import org.eclipse.trace4cps.core.TraceException; * An exception specific for Trace parsing. */ public class ParseException extends TraceException { - private static final long serialVersionUID = 1L; public ParseException() { diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/TraceReader.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/TraceReader.java index c00d253c6eb90101949687f8cfb7a0dfaaf7418f..9ce66071f2a95b09372035eda22c469cc249762d 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/TraceReader.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/TraceReader.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.io; import java.io.BufferedReader; @@ -34,13 +35,11 @@ import org.eclipse.trace4cps.core.impl.Resource; import org.eclipse.trace4cps.core.impl.Trace; /** - * Class used to read an {@link ITrace} instance from its textual representation. Note that that the attribute - * keys and values are trimmed with {@link String#trim()}. Furthermore, the time stamps ({@link Number} - * instances in the API) are read as {@code double} values, except for the {@link ITrace#getTimeOffset()}, - * which is read as a {@code long} value. + * Class used to read an {@link ITrace} instance from its textual representation. Note that that the attribute keys and + * values are trimmed with {@link String#trim()}. Furthermore, the time stamps ({@link Number} instances in the API) are + * read as {@code double} values, except for the {@link ITrace#getTimeOffset()}, which is read as a {@code long} value. */ public class TraceReader { - public static final String FILENAME_ATT = "name"; private static final String WHITESPACE = "\\s+"; @@ -96,7 +95,7 @@ public class TraceReader { /** * Creates a {@link ITrace} from a string. - * + * * @param s the textual representation of the trace * @return the corresponding {@link ITrace} instance * @throws ParseException if the input is not valid @@ -108,7 +107,7 @@ public class TraceReader { /** * Creates a {@link ITrace} from an input stream. - * + * * @param in the stream with the textual representation of the trace * @return the corresponding {@link ITrace} instance * @throws ParseException if the input is not valid @@ -120,7 +119,7 @@ public class TraceReader { /** * Creates a {@link ITrace} from a file. - * + * * @param f the file with the textual representation of the trace * @return the corresponding {@link ITrace} instance * @throws ParseException if the input is not valid @@ -179,7 +178,7 @@ public class TraceReader { } private void validatePsops() throws ParseException { - for (IPsop p : signalMap.values()) { + for (IPsop p: signalMap.values()) { if (!p.getFragments().isEmpty()) { trace.add(p); } @@ -219,15 +218,14 @@ public class TraceReader { throw new ParseException(msg); } if (splitIndex + 1 < line.length()) { - for (Map.Entry e : parseAttributes(line.substring(splitIndex + 1)).entrySet()) { + for (Map.Entry e: parseAttributes(line.substring(splitIndex + 1)).entrySet()) { trace.setAttribute(e.getKey(), e.getValue()); } } } private void parseResource(String line) throws ParseException { - final String msg = - "Expected 'R' ';' * on line " + lineNumber; + final String msg = "Expected 'R' ';' * on line " + lineNumber; int splitIndex = line.indexOf(ATTRIBUTE_START); if (splitIndex <= 0) { throw new ParseException(msg); @@ -276,8 +274,7 @@ public class TraceReader { "Could not resolve dependency reference " + sourceId + " on line " + lineNumber); } if (events[1] == null) { - throw new ParseException( - "Could not resolve dependency reference " + dstId + " on line " + lineNumber); + throw new ParseException("Could not resolve dependency reference " + dstId + " on line " + lineNumber); } Dependency dep = new Dependency(events[0], events[1]); dep.setAttributes(parseAttributes(part2)); @@ -290,44 +287,44 @@ public class TraceReader { private Event[] getEvents(int dependencyType, int id1, int id2) throws ParseException { Event[] events = new Event[2]; switch (DependencyType.typeFor(dependencyType)) { - case EVENT_EVENT: - events[0] = eventMap.get(id1); - events[1] = eventMap.get(id2); - break; - case EVENT_CLAIM_START: - events[0] = eventMap.get(id1); - events[1] = (Event) claimMap.get(id2).getStartEvent(); - break; - case EVENT_CLAIM_END: - events[0] = eventMap.get(id1); - events[1] = (Event) claimMap.get(id2).getEndEvent(); - break; - case CLAIM_START_EVENT: - events[0] = (Event) claimMap.get(id1).getStartEvent(); - events[1] = eventMap.get(id2); - break; - case CLAIM_END_EVENT: - events[0] = (Event) claimMap.get(id1).getEndEvent(); - events[1] = eventMap.get(id2); - break; - case CLAIM_START_CLAIM_START: - events[0] = (Event) claimMap.get(id1).getStartEvent(); - events[1] = (Event) claimMap.get(id2).getStartEvent(); - break; - case CLAIM_START_CLAIM_END: - events[0] = (Event) claimMap.get(id1).getStartEvent(); - events[1] = (Event) claimMap.get(id2).getEndEvent(); - break; - case CLAIM_END_CLAIM_START: - events[0] = (Event) claimMap.get(id1).getEndEvent(); - events[1] = (Event) claimMap.get(id2).getStartEvent(); - break; - case CLAIM_END_CLAIM_END: - events[0] = (Event) claimMap.get(id1).getEndEvent(); - events[1] = (Event) claimMap.get(id2).getEndEvent(); - break; - default: - throw new ParseException("Unknown dependency type " + dependencyType + " in line " + lineNumber); + case EVENT_EVENT: + events[0] = eventMap.get(id1); + events[1] = eventMap.get(id2); + break; + case EVENT_CLAIM_START: + events[0] = eventMap.get(id1); + events[1] = (Event)claimMap.get(id2).getStartEvent(); + break; + case EVENT_CLAIM_END: + events[0] = eventMap.get(id1); + events[1] = (Event)claimMap.get(id2).getEndEvent(); + break; + case CLAIM_START_EVENT: + events[0] = (Event)claimMap.get(id1).getStartEvent(); + events[1] = eventMap.get(id2); + break; + case CLAIM_END_EVENT: + events[0] = (Event)claimMap.get(id1).getEndEvent(); + events[1] = eventMap.get(id2); + break; + case CLAIM_START_CLAIM_START: + events[0] = (Event)claimMap.get(id1).getStartEvent(); + events[1] = (Event)claimMap.get(id2).getStartEvent(); + break; + case CLAIM_START_CLAIM_END: + events[0] = (Event)claimMap.get(id1).getStartEvent(); + events[1] = (Event)claimMap.get(id2).getEndEvent(); + break; + case CLAIM_END_CLAIM_START: + events[0] = (Event)claimMap.get(id1).getEndEvent(); + events[1] = (Event)claimMap.get(id2).getStartEvent(); + break; + case CLAIM_END_CLAIM_END: + events[0] = (Event)claimMap.get(id1).getEndEvent(); + events[1] = (Event)claimMap.get(id2).getEndEvent(); + break; + default: + throw new ParseException("Unknown dependency type " + dependencyType + " in line " + lineNumber); } return events; } @@ -364,7 +361,6 @@ public class TraceReader { throw new ParseException(msg); } try { - int id = Integer.parseInt(res[1]); double t0 = Double.parseDouble(res[2]); double t1 = Double.parseDouble(res[3]); @@ -396,8 +392,7 @@ public class TraceReader { private void ensureConsecutive(Psop p, double t0) throws ParseException { if (p.getFragments().size() > 0) { - double endOfPreviousTime = - p.getFragments().get(p.getFragments().size() - 1).dom().ub().doubleValue(); + double endOfPreviousTime = p.getFragments().get(p.getFragments().size() - 1).dom().ub().doubleValue(); if (endOfPreviousTime != t0) { throw new ParseException("Non-consecutive fragment on line " + lineNumber + ", end of previous fragment: " + endOfPreviousTime); @@ -433,9 +428,8 @@ public class TraceReader { } private void parseClaim(String line) throws ParseException { - final String msg = - "Expected 'C' ? ';' * on line " - + lineNumber; + final String msg = "Expected 'C' ? ';' * on line " + + lineNumber; int splitIndex = line.indexOf(ATTRIBUTE_START); if (splitIndex <= 0) { throw new ParseException(msg); @@ -498,7 +492,7 @@ public class TraceReader { StringBuilder value = new StringBuilder(); i = readKey(line, i, key); i = readValue(line, i, value); - m.put(key.toString().trim(), value.toString().trim());// TODO: remove escaped characters + m.put(key.toString().trim(), value.toString().trim()); // TODO: remove escaped characters } } return m; diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/TraceWriter.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/TraceWriter.java index 09a47e73dbe281219f235f44d9dd2eb9f41e43a1..7f6483ed17a0ae3396e1144797e6167ea5f97a74 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/TraceWriter.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/TraceWriter.java @@ -7,9 +7,25 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.io; -import static org.eclipse.trace4cps.core.io.TraceReader.*; +import static org.eclipse.trace4cps.core.io.TraceReader.ATTRIBUTE_ASSIGN; +import static org.eclipse.trace4cps.core.io.TraceReader.ATTRIBUTE_ASSIGN_STR; +import static org.eclipse.trace4cps.core.io.TraceReader.ATTRIBUTE_DELIMITER; +import static org.eclipse.trace4cps.core.io.TraceReader.ATTRIBUTE_DELIMITER_STR; +import static org.eclipse.trace4cps.core.io.TraceReader.ATTRIBUTE_START; +import static org.eclipse.trace4cps.core.io.TraceReader.CLAIM_TAG; +import static org.eclipse.trace4cps.core.io.TraceReader.DEPENDENCY_TAG; +import static org.eclipse.trace4cps.core.io.TraceReader.EVENT_TAG; +import static org.eclipse.trace4cps.core.io.TraceReader.NEW_LINE; +import static org.eclipse.trace4cps.core.io.TraceReader.OFFSET_TAG; +import static org.eclipse.trace4cps.core.io.TraceReader.PSOP_FRAGMENT_TAG; +import static org.eclipse.trace4cps.core.io.TraceReader.PSOP_TAG; +import static org.eclipse.trace4cps.core.io.TraceReader.RESOURCE_TAG; +import static org.eclipse.trace4cps.core.io.TraceReader.SPACE; +import static org.eclipse.trace4cps.core.io.TraceReader.TIMEUNIT_TAG; +import static org.eclipse.trace4cps.core.io.TraceReader.TRACE_TAG; import java.io.BufferedWriter; import java.io.File; @@ -29,13 +45,11 @@ import org.eclipse.trace4cps.core.ITrace; import org.eclipse.trace4cps.core.impl.ClaimEvent; /** - * Class used to write an {@link ITrace} instance to a file. Note that that the attribute keys and values are - * trimmed with {@link String#trim()}. Furthermore, the time stamps ({@link Number} instances) are written as - * {@code double} values, except for the {@link ITrace#getTimeOffset()}, which is written as a {@code long} - * value. + * Class used to write an {@link ITrace} instance to a file. Note that that the attribute keys and values are trimmed + * with {@link String#trim()}. Furthermore, the time stamps ({@link Number} instances) are written as {@code double} + * values, except for the {@link ITrace#getTimeOffset()}, which is written as a {@code long} value. */ public class TraceWriter { - private final Map resourceMap = new HashMap<>(); private final Map claimMap = new HashMap<>(); @@ -47,7 +61,7 @@ public class TraceWriter { /** * Writes a given {@link ITrace} to a given file. - * + * * @param trace the trace to write * @param f the destination file * @throws IOException if an error occurs @@ -93,7 +107,7 @@ public class TraceWriter { private void writeResources(ITrace trace, BufferedWriter w) throws IOException { int id = 0; - for (IResource r : trace.getResources()) { + for (IResource r: trace.getResources()) { resourceMap.put(r, id); w.write(RESOURCE_TAG); w.write(SPACE); @@ -110,7 +124,7 @@ public class TraceWriter { private void writeClaims(ITrace trace, BufferedWriter w) throws IOException { int id = 0; - for (IClaim c : trace.getClaims()) { + for (IClaim c: trace.getClaims()) { claimMap.put(c, id); w.write(CLAIM_TAG); w.write(SPACE); @@ -140,7 +154,7 @@ public class TraceWriter { private void writeEvents(ITrace trace, BufferedWriter w) throws IOException { int id = 0; - for (IEvent e : trace.getEvents()) { + for (IEvent e: trace.getEvents()) { if (!(e instanceof ClaimEvent)) { eventMap.put(e, id); w.write(EVENT_TAG); @@ -157,7 +171,7 @@ public class TraceWriter { private void writeDependencies(ITrace trace, BufferedWriter w) throws IOException { int id = 0; - for (IDependency d : trace.getDependencies()) { + for (IDependency d: trace.getDependencies()) { Integer[] typeAndIds = getTypeAndIds(d); if (typeAndIds[1] == null || typeAndIds[2] == null) { throw new IOException("Cannot resolve claim or event id in dependency " + d); @@ -188,7 +202,7 @@ public class TraceWriter { result[1] = eventMap.get(src); result[2] = eventMap.get(dst); } else if (!srcClaimEvent && dstClaimEvent) { - ClaimEvent d = (ClaimEvent) dst; + ClaimEvent d = (ClaimEvent)dst; result[1] = eventMap.get(src); result[2] = claimMap.get(d.getClaim()); if (d.getType() == ClaimEventType.START) { @@ -197,7 +211,7 @@ public class TraceWriter { result[0] = DependencyType.EVENT_CLAIM_END.getValue(); } } else if (srcClaimEvent && !dstClaimEvent) { // srcClaimEvent && !dstClaimEvent - ClaimEvent s = (ClaimEvent) src; + ClaimEvent s = (ClaimEvent)src; result[1] = claimMap.get(s.getClaim()); result[2] = eventMap.get(dst); if (s.getType() == ClaimEventType.START) { @@ -206,8 +220,8 @@ public class TraceWriter { result[0] = DependencyType.CLAIM_END_EVENT.getValue(); } } else { // srcClaimEvent && dstClaimEvent - ClaimEvent s = (ClaimEvent) src; - ClaimEvent d = (ClaimEvent) dst; + ClaimEvent s = (ClaimEvent)src; + ClaimEvent d = (ClaimEvent)dst; result[1] = claimMap.get(s.getClaim()); result[2] = claimMap.get(d.getClaim()); if (s.getType() == ClaimEventType.START && d.getType() == ClaimEventType.START) { @@ -225,7 +239,7 @@ public class TraceWriter { private void writeSignals(ITrace trace, BufferedWriter w) throws IOException { int id = 0; - for (IPsop p : trace.getSignals()) { + for (IPsop p: trace.getSignals()) { w.write(PSOP_TAG); w.write(SPACE); w.write(Integer.toString(id)); @@ -237,7 +251,7 @@ public class TraceWriter { } private void writeFragments(IPsop p, int signalId, BufferedWriter w) throws IOException { - for (IPsopFragment f : p.getFragments()) { + for (IPsopFragment f: p.getFragments()) { w.write(PSOP_FRAGMENT_TAG); w.write(SPACE); w.write(Integer.toString(signalId)); @@ -257,7 +271,7 @@ public class TraceWriter { private void writeAttributes(Map attributes, BufferedWriter w) throws IOException { int cnt = 0; - for (Map.Entry e : attributes.entrySet()) { + for (Map.Entry e: attributes.entrySet()) { cnt++; String key = escape(e.getKey()).trim(); String val = escape(e.getValue()).trim(); @@ -278,7 +292,7 @@ public class TraceWriter { } private String escape(String str) { - return str.replace(ATTRIBUTE_DELIMITER_STR, "\\" + ATTRIBUTE_DELIMITER_STR) - .replace(ATTRIBUTE_ASSIGN_STR, "\\" + ATTRIBUTE_ASSIGN_STR); + return str.replace(ATTRIBUTE_DELIMITER_STR, "\\" + ATTRIBUTE_DELIMITER_STR).replace(ATTRIBUTE_ASSIGN_STR, + "\\" + ATTRIBUTE_ASSIGN_STR); } } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/Attribute.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/Attribute.java index eb99b2376f6acdbe62fec82a57319fecdba65e49..6bb05228ce3da394713a17bce17e9c4294ef5a8f 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/Attribute.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/Attribute.java @@ -7,220 +7,182 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.io.conv; import java.util.ArrayList; import java.util.List; /** - * * An implementation of the model object 'Attribute'. - * *

    * The following features are implemented: *

      - *
    • {@link nl.esi.trace.model.ganttchart.Attribute#getAttributeID Attribute ID}
    • - *
    • {@link nl.esi.trace.model.ganttchart.Attribute#getAttributeName Attribute Name}
    • - *
    • {@link nl.esi.trace.model.ganttchart.Attribute#getAttributeValueType Attribute Value Type}
    • - *
    • {@link nl.esi.trace.datamodel Attribute#isAttributeInternal Attribute Internal}
    • - *
    • {@link nl.esi.trace.model.ganttchart.Attribute#getAttributeUsages Attribute Usages}
    • + *
    • {@link nl.esi.trace.model.ganttchart.Attribute#getAttributeID Attribute ID}
    • + *
    • {@link nl.esi.trace.model.ganttchart.Attribute#getAttributeName Attribute Name}
    • + *
    • {@link nl.esi.trace.model.ganttchart.Attribute#getAttributeValueType Attribute Value Type}
    • + *
    • {@link nl.esi.trace.datamodel Attribute#isAttributeInternal Attribute Internal}
    • + *
    • {@link nl.esi.trace.model.ganttchart.Attribute#getAttributeUsages Attribute Usages}
    • *
    *

    */ public class Attribute extends Object { - /** - * The default value of the '{@link #getAttributeID() Attribute ID}' attribute. - * - * - * @see #getAttributeID() - */ - protected static final int ATTRIBUTE_ID_DEFAULT = 0; - - /** - * The cached value of the '{@link #getAttributeID() Attribute ID}' attribute. - * - * - * @see #getAttributeID() - */ - protected int attributeID = ATTRIBUTE_ID_DEFAULT; - - /** - * The default value of the '{@link #getAttributeName() Attribute Name}' attribute. - * - * - * @see #getAttributeName() - */ - protected static final String ATTRIBUTE_NAME_DEFAULT = null; - - /** - * The cached value of the '{@link #getAttributeName() Attribute Name}' attribute. - * - * - * @see #getAttributeName() - */ - protected String attributeName = ATTRIBUTE_NAME_DEFAULT; - - /** - * The default value of the '{@link #getAttributeValueType() Attribute Value Type}' attribute. - * - * - * @see #getAttributeValueType() - */ - protected static final AttributeValueType ATTRIBUTE_VALUE_TYPE_DEFAULT = AttributeValueType.STRING; - - /** - * The cached value of the '{@link #getAttributeValueType() Attribute Value Type}' attribute. - * - * - * @see #getAttributeValueType() - */ - protected AttributeValueType attributeValueType = ATTRIBUTE_VALUE_TYPE_DEFAULT; - - /** - * The default value of the '{@link #isAttributeInternal() Attribute Internal}' attribute. - * - * - * @see #isAttributeInternal() - */ - protected static final boolean ATTRIBUTE_INTERNAL_DEFAULT = false; - - /** - * The cached value of the '{@link #isAttributeInternal() Attribute Internal}' attribute. - * - * - * @see #isAttributeInternal() - */ - protected boolean attributeInternal = ATTRIBUTE_INTERNAL_DEFAULT; - - /** - * The cached value of the '{@link #getAttributeUsages() Attribute Usages}' attribute list. - * - * - * @see #getAttributeUsages() - */ - protected ArrayList attributeUsages; - - /** - * The cached value of the '{@link #getAttributeFilteringValues() Filtering Values}' attribute list. - * - * - * @see #getAttributeFilteringValue() - */ - protected ArrayList attributeFilteringValues = new ArrayList(); - - /** - * - * - */ - public Attribute() { - super(); - } - - /** - * - * - */ - public int getAttributeID() { - return attributeID; - } - - /** - * - * - */ - public void setAttributeID(int newAttributeID) { - attributeID = newAttributeID; - } - - /** - * - * - */ - public String getAttributeName() { - return attributeName; - } - - /** - * - * - */ - public void setAttributeName(String newAttributeName) { - attributeName = newAttributeName; - } - - /** - * - * - */ - public AttributeValueType getAttributeValueType() { - return attributeValueType; - } - - /** - * - * - */ - public void setAttributeValueType(AttributeValueType newAttributeValueType) { - attributeValueType = newAttributeValueType == null ? ATTRIBUTE_VALUE_TYPE_DEFAULT : newAttributeValueType; - } - - /** - * - * - */ - public boolean isAttributeInternal() { - return attributeInternal; - } - - /** - * - * - */ - public void setAttributeInternal(boolean newAttributeInternal) { - attributeInternal = newAttributeInternal; - } - - /** - * - * - */ - public List getAttributeUsages() { - if (attributeUsages == null) { - attributeUsages = new ArrayList(); - } - return attributeUsages; - } - - /** - * - * - */ - public ArrayList getAttributeFilteringValues() { - return attributeFilteringValues; - } - - /** - * - * - */ - public void setAttributeFilteringValues(ArrayList filteringValue) { - this.attributeFilteringValues = filteringValue; - } - - /** - * - * - */ - @Override - public String toString() { - StringBuffer result = new StringBuffer('('); - result.append("[ID: " + attributeID); - result.append(", Name: " + attributeName); - result.append(", ValueType: " + attributeValueType); - result.append(", Internal: " + attributeInternal); - result.append(", Usages: " + attributeUsages); - result.append(']'); - return result.toString(); - } - + /** + * The default value of the '{@link #getAttributeID() Attribute ID}' attribute. + * + * @see #getAttributeID() + */ + protected static final int ATTRIBUTE_ID_DEFAULT = 0; + + /** + * The cached value of the '{@link #getAttributeID() Attribute ID}' attribute. + * + * @see #getAttributeID() + */ + protected int attributeID = ATTRIBUTE_ID_DEFAULT; + + /** + * The default value of the '{@link #getAttributeName() Attribute Name}' attribute. + * + * @see #getAttributeName() + */ + protected static final String ATTRIBUTE_NAME_DEFAULT = null; + + /** + * The cached value of the '{@link #getAttributeName() Attribute Name}' attribute. + * + * @see #getAttributeName() + */ + protected String attributeName = ATTRIBUTE_NAME_DEFAULT; + + /** + * The default value of the '{@link #getAttributeValueType() Attribute Value Type}' attribute. + * + * @see #getAttributeValueType() + */ + protected static final AttributeValueType ATTRIBUTE_VALUE_TYPE_DEFAULT = AttributeValueType.STRING; + + /** + * The cached value of the '{@link #getAttributeValueType() Attribute Value Type}' attribute. + * + * @see #getAttributeValueType() + */ + protected AttributeValueType attributeValueType = ATTRIBUTE_VALUE_TYPE_DEFAULT; + + /** + * The default value of the '{@link #isAttributeInternal() Attribute Internal}' attribute. + * + * @see #isAttributeInternal() + */ + protected static final boolean ATTRIBUTE_INTERNAL_DEFAULT = false; + + /** + * The cached value of the '{@link #isAttributeInternal() Attribute Internal}' attribute. + * + * @see #isAttributeInternal() + */ + protected boolean attributeInternal = ATTRIBUTE_INTERNAL_DEFAULT; + + /** + * The cached value of the '{@link #getAttributeUsages() Attribute Usages}' attribute list. + * + * @see #getAttributeUsages() + */ + protected ArrayList attributeUsages; + + /** + * The cached value of the '{@link #getAttributeFilteringValues() Filtering Values}' attribute list. + * + * @see #getAttributeFilteringValue() + */ + protected ArrayList attributeFilteringValues = new ArrayList(); + + /** + */ + public Attribute() { + super(); + } + + /** + */ + public int getAttributeID() { + return attributeID; + } + + /** + */ + public void setAttributeID(int newAttributeID) { + attributeID = newAttributeID; + } + + /** + */ + public String getAttributeName() { + return attributeName; + } + + /** + */ + public void setAttributeName(String newAttributeName) { + attributeName = newAttributeName; + } + + /** + */ + public AttributeValueType getAttributeValueType() { + return attributeValueType; + } + + /** + */ + public void setAttributeValueType(AttributeValueType newAttributeValueType) { + attributeValueType = newAttributeValueType == null ? ATTRIBUTE_VALUE_TYPE_DEFAULT : newAttributeValueType; + } + + /** + */ + public boolean isAttributeInternal() { + return attributeInternal; + } + + /** + */ + public void setAttributeInternal(boolean newAttributeInternal) { + attributeInternal = newAttributeInternal; + } + + /** + */ + public List getAttributeUsages() { + if (attributeUsages == null) { + attributeUsages = new ArrayList(); + } + return attributeUsages; + } + + /** + */ + public ArrayList getAttributeFilteringValues() { + return attributeFilteringValues; + } + + /** + */ + public void setAttributeFilteringValues(ArrayList filteringValue) { + this.attributeFilteringValues = filteringValue; + } + + /** + */ + @Override + public String toString() { + StringBuffer result = new StringBuffer('('); + result.append("[ID: " + attributeID); + result.append(", Name: " + attributeName); + result.append(", ValueType: " + attributeValueType); + result.append(", Internal: " + attributeInternal); + result.append(", Usages: " + attributeUsages); + result.append(']'); + return result.toString(); + } } // Attribute diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/AttributeUsageType.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/AttributeUsageType.java index 7271f1501367a787a31946295c6f3f9d7d5c73ff..21f62a97862409ed849e1af4386a38b4d974032a 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/AttributeUsageType.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/AttributeUsageType.java @@ -7,254 +7,215 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.io.conv; import java.util.Arrays; import java.util.Collections; import java.util.List; - /** - * - * A representation of the literals of the enumeration 'Attribute Usage Type', - * and utility methods for working with them. - * - * @see {@code nl.esi.trace.model.TracePackage#getAttributeUsageType()} + * A representation of the literals of the enumeration 'Attribute Usage Type', and utility methods for + * working with them. + * + * @see nl.esi.trace.model.TracePackage#getAttributeUsageType() */ public enum AttributeUsageType { - /** - * The 'Describing' literal object. - * - * - * @see #DESCRIBING_VALUE - */ - DESCRIBING(1, "Describing", "Describing"), - - /** - * The 'Labeling' literal object. - * - * - * @see #LABELING_VALUE - */ - LABELING(2, "Labeling", "Labeling"), - - /** - * The 'Filtering' literal object. - * - * - * @see #FILTERING_VALUE - */ - FILTERING(3, "Filtering", "Filtering"), - - /** - * The 'Grouping' literal object. - * - * - * @see #GROUPING_VALUE - */ - GROUPING(4, "Grouping", "Grouping"), - - /** - * The 'Coloring' literal object. - * - * - * @see #COLORING_VALUE - */ - COLORING(5, "Coloring", "Coloring"); - - /** - * The 'Describing' literal value. - * - *

    - * If the meaning of 'Describing' literal object isn't clear, - * there really should be more of a description here... - *

    - * - * @see #DESCRIBING - * @model name="Describing" - */ - public static final int DESCRIBING_VALUE = 1; - - /** - * The 'Labeling' literal value. - * - *

    - * If the meaning of 'Labeling' literal object isn't clear, - * there really should be more of a description here... - *

    - * - * @see #LABELING - * @model name="Labeling" - */ - public static final int LABELING_VALUE = 2; - - /** - * The 'Filtering' literal value. - * - *

    - * If the meaning of 'Filtering' literal object isn't clear, - * there really should be more of a description here... - *

    - * - * @see #FILTERING - * @model name="Filtering" - */ - public static final int FILTERING_VALUE = 3; - - /** - * The 'Grouping' literal value. - * - *

    - * If the meaning of 'Grouping' literal object isn't clear, - * there really should be more of a description here... - *

    - * - * @see #GROUPING - * @model name="Grouping" - */ - public static final int GROUPING_VALUE = 4; - - /** - * The 'Coloring' literal value. - * - *

    - * If the meaning of 'Coloring' literal object isn't clear, - * there really should be more of a description here... - *

    - * - * @see #COLORING - * @model name="Coloring" - */ - public static final int COLORING_VALUE = 5; - - /** - * An array of all the 'Attribute Usage Type' enumerators. - * - * - */ - private static final AttributeUsageType[] VALUES_ARRAY = - new AttributeUsageType[] { - DESCRIBING, - LABELING, - FILTERING, - GROUPING, - COLORING, - }; - - /** - * A public read-only list of all the 'Attribute Usage Type' enumerators. - * - * - */ - public static final List VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY)); - - /** - * Returns the 'Attribute Usage Type' literal with the specified literal value. - * - * - */ - public static AttributeUsageType get(String literal) { - for (int i = 0; i < VALUES_ARRAY.length; ++i) { - AttributeUsageType result = VALUES_ARRAY[i]; - if (result.toString().equals(literal)) { - return result; - } - } - return null; - } - - /** - * Returns the 'Attribute Usage Type' literal with the specified name. - * - * - */ - public static AttributeUsageType getByName(String name) { - for (int i = 0; i < VALUES_ARRAY.length; ++i) { - AttributeUsageType result = VALUES_ARRAY[i]; - if (result.getName().equals(name)) { - return result; - } - } - return null; - } - - /** - * Returns the 'Attribute Usage Type' literal with the specified integer value. - * - * - */ - public static AttributeUsageType get(int value) { - switch (value) { - case DESCRIBING_VALUE: return DESCRIBING; - case LABELING_VALUE: return LABELING; - case FILTERING_VALUE: return FILTERING; - case GROUPING_VALUE: return GROUPING; - case COLORING_VALUE: return COLORING; - } - return null; - } - - /** - * - * - */ - private final int value; - - /** - * - * - */ - private final String name; - - /** - * - * - */ - private final String literal; - - /** - * Only this class can construct instances. - * - * - */ - private AttributeUsageType(int value, String name, String literal) { - this.value = value; - this.name = name; - this.literal = literal; - } - - /** - * - * - */ - public int getValue() { - return value; - } - - /** - * - * - */ - public String getName() { - return name; - } - - /** - * - * - */ - public String getLiteral() { - return literal; - } - - /** - * Returns the literal value of the enumerator, which is its string representation. - * - * - */ - @Override - public String toString() { - return literal; - } - + /** + * The 'Describing' literal object. + * + * @see #DESCRIBING_VALUE + */ + DESCRIBING(1, "Describing", "Describing"), + + /** + * The 'Labeling' literal object. + * + * @see #LABELING_VALUE + */ + LABELING(2, "Labeling", "Labeling"), + + /** + * The 'Filtering' literal object. + * + * @see #FILTERING_VALUE + */ + FILTERING(3, "Filtering", "Filtering"), + + /** + * The 'Grouping' literal object. + * + * @see #GROUPING_VALUE + */ + GROUPING(4, "Grouping", "Grouping"), + + /** + * The 'Coloring' literal object. + * + * @see #COLORING_VALUE + */ + COLORING(5, "Coloring", "Coloring"); + + /** + * The 'Describing' literal value. + *

    + * If the meaning of 'Describing' literal object isn't clear, there really should be more of a + * description here... + *

    + * + * @see #DESCRIBING + * @model name="Describing" + */ + public static final int DESCRIBING_VALUE = 1; + + /** + * The 'Labeling' literal value. + *

    + * If the meaning of 'Labeling' literal object isn't clear, there really should be more of a + * description here... + *

    + * + * @see #LABELING + * @model name="Labeling" + */ + public static final int LABELING_VALUE = 2; + + /** + * The 'Filtering' literal value. + *

    + * If the meaning of 'Filtering' literal object isn't clear, there really should be more of a + * description here... + *

    + * + * @see #FILTERING + * @model name="Filtering" + */ + public static final int FILTERING_VALUE = 3; + + /** + * The 'Grouping' literal value. + *

    + * If the meaning of 'Grouping' literal object isn't clear, there really should be more of a + * description here... + *

    + * + * @see #GROUPING + * @model name="Grouping" + */ + public static final int GROUPING_VALUE = 4; + + /** + * The 'Coloring' literal value. + *

    + * If the meaning of 'Coloring' literal object isn't clear, there really should be more of a + * description here... + *

    + * + * @see #COLORING + * @model name="Coloring" + */ + public static final int COLORING_VALUE = 5; + + /** + * An array of all the 'Attribute Usage Type' enumerators. + */ + private static final AttributeUsageType[] VALUES_ARRAY = new AttributeUsageType[] {DESCRIBING, LABELING, FILTERING, + GROUPING, COLORING}; + + /** + * A public read-only list of all the 'Attribute Usage Type' enumerators. + */ + public static final List VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY)); + + /** + * Returns the 'Attribute Usage Type' literal with the specified literal value. + */ + public static AttributeUsageType get(String literal) { + for (int i = 0; i < VALUES_ARRAY.length; ++i) { + AttributeUsageType result = VALUES_ARRAY[i]; + if (result.toString().equals(literal)) { + return result; + } + } + return null; + } + + /** + * Returns the 'Attribute Usage Type' literal with the specified name. + */ + public static AttributeUsageType getByName(String name) { + for (int i = 0; i < VALUES_ARRAY.length; ++i) { + AttributeUsageType result = VALUES_ARRAY[i]; + if (result.getName().equals(name)) { + return result; + } + } + return null; + } + + /** + * Returns the 'Attribute Usage Type' literal with the specified integer value. + */ + public static AttributeUsageType get(int value) { + switch (value) { + case DESCRIBING_VALUE: + return DESCRIBING; + case LABELING_VALUE: + return LABELING; + case FILTERING_VALUE: + return FILTERING; + case GROUPING_VALUE: + return GROUPING; + case COLORING_VALUE: + return COLORING; + } + return null; + } + + /** + */ + private final int value; + + /** + */ + private final String name; + + /** + */ + private final String literal; + + /** + * Only this class can construct instances. + */ + private AttributeUsageType(int value, String name, String literal) { + this.value = value; + this.name = name; + this.literal = literal; + } + + /** + */ + public int getValue() { + return value; + } + + /** + */ + public String getName() { + return name; + } + + /** + */ + public String getLiteral() { + return literal; + } + + /** + * Returns the literal value of the enumerator, which is its string representation. + */ + @Override + public String toString() { + return literal; + } } // AttributeUsageType diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/AttributeValueType.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/AttributeValueType.java index 3b792670c78fd3e19ceee717ac2f8ff19777c85f..a8a7815e5973ad292fbb89dbfc2c54391c2d045a 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/AttributeValueType.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/AttributeValueType.java @@ -7,185 +7,151 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.io.conv; import java.util.Arrays; import java.util.Collections; import java.util.List; - /** - * - * A representation of the literals of the enumeration 'Attribute Value Type', - * and utility methods for working with them. - * + * A representation of the literals of the enumeration 'Attribute Value Type', and utility methods for + * working with them. + * * @see nl.esi.trace.datamodel.TracePackage#getAttributeValueType() */ public enum AttributeValueType { - /** - * The 'String' literal object. - * - * - * @see #STRING_VALUE - */ - STRING(0, "String", "String"), - - /** - * The 'Double' literal object. - * - * - * @see #DOUBLE_VALUE - */ - DOUBLE(1, "Double", "Double"); - - /** - * The 'String' literal value. - * - *

    - * If the meaning of 'String' literal object isn't clear, - * there really should be more of a description here... - *

    - * - * @see #STRING - * @model name="String" - */ - public static final int STRING_VALUE = 0; - - /** - * The 'Double' literal value. - * - *

    - * If the meaning of 'Double' literal object isn't clear, - * there really should be more of a description here... - *

    - * - * @see #DOUBLE - * @model name="Double" - */ - public static final int DOUBLE_VALUE = 1; - - /** - * An array of all the 'Attribute Value Type' enumerators. - * - * - */ - private static final AttributeValueType[] VALUES_ARRAY = - new AttributeValueType[] { - STRING, - DOUBLE, - }; - - /** - * A public read-only list of all the 'Attribute Value Type' enumerators. - * - * - */ - public static final List VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY)); - - /** - * Returns the 'Attribute Value Type' literal with the specified literal value. - * - * - */ - public static AttributeValueType get(String literal) { - for (int i = 0; i < VALUES_ARRAY.length; ++i) { - AttributeValueType result = VALUES_ARRAY[i]; - if (result.toString().equals(literal)) { - return result; - } - } - return null; - } - - /** - * Returns the 'Attribute Value Type' literal with the specified name. - * - * - */ - public static AttributeValueType getByName(String name) { - for (int i = 0; i < VALUES_ARRAY.length; ++i) { - AttributeValueType result = VALUES_ARRAY[i]; - if (result.getName().equals(name)) { - return result; - } - } - return null; - } - - /** - * Returns the 'Attribute Value Type' literal with the specified integer value. - * - * - */ - public static AttributeValueType get(int value) { - switch (value) { - case STRING_VALUE: return STRING; - case DOUBLE_VALUE: return DOUBLE; - } - return null; - } - - /** - * - * - */ - private final int value; - - /** - * - * - */ - private final String name; - - /** - * - * - */ - private final String literal; - - /** - * Only this class can construct instances. - * - * - */ - private AttributeValueType(int value, String name, String literal) { - this.value = value; - this.name = name; - this.literal = literal; - } - - /** - * - * - */ - public int getValue() { - return value; - } - - /** - * - * - */ - public String getName() { - return name; - } - - /** - * - * - */ - public String getLiteral() { - return literal; - } - - /** - * Returns the literal value of the enumerator, which is its string representation. - * - * - */ - @Override - public String toString() { - return literal; - } - + /** + * The 'String' literal object. + * + * @see #STRING_VALUE + */ + STRING(0, "String", "String"), + + /** + * The 'Double' literal object. + * + * @see #DOUBLE_VALUE + */ + DOUBLE(1, "Double", "Double"); + + /** + * The 'String' literal value. + *

    + * If the meaning of 'String' literal object isn't clear, there really should be more of a + * description here... + *

    + * + * @see #STRING + * @model name="String" + */ + public static final int STRING_VALUE = 0; + + /** + * The 'Double' literal value. + *

    + * If the meaning of 'Double' literal object isn't clear, there really should be more of a + * description here... + *

    + * + * @see #DOUBLE + * @model name="Double" + */ + public static final int DOUBLE_VALUE = 1; + + /** + * An array of all the 'Attribute Value Type' enumerators. + */ + private static final AttributeValueType[] VALUES_ARRAY = new AttributeValueType[] {STRING, DOUBLE}; + + /** + * A public read-only list of all the 'Attribute Value Type' enumerators. + */ + public static final List VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY)); + + /** + * Returns the 'Attribute Value Type' literal with the specified literal value. + */ + public static AttributeValueType get(String literal) { + for (int i = 0; i < VALUES_ARRAY.length; ++i) { + AttributeValueType result = VALUES_ARRAY[i]; + if (result.toString().equals(literal)) { + return result; + } + } + return null; + } + + /** + * Returns the 'Attribute Value Type' literal with the specified name. + */ + public static AttributeValueType getByName(String name) { + for (int i = 0; i < VALUES_ARRAY.length; ++i) { + AttributeValueType result = VALUES_ARRAY[i]; + if (result.getName().equals(name)) { + return result; + } + } + return null; + } + + /** + * Returns the 'Attribute Value Type' literal with the specified integer value. + */ + public static AttributeValueType get(int value) { + switch (value) { + case STRING_VALUE: + return STRING; + case DOUBLE_VALUE: + return DOUBLE; + } + return null; + } + + /** + */ + private final int value; + + /** + */ + private final String name; + + /** + */ + private final String literal; + + /** + * Only this class can construct instances. + */ + private AttributeValueType(int value, String name, String literal) { + this.value = value; + this.name = name; + this.literal = literal; + } + + /** + */ + public int getValue() { + return value; + } + + /** + */ + public String getName() { + return name; + } + + /** + */ + public String getLiteral() { + return literal; + } + + /** + * Returns the literal value of the enumerator, which is its string representation. + */ + @Override + public String toString() { + return literal; + } } // AttributeValueType diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/ClaimType.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/ClaimType.java index 23f2af3ec5c86ee96e8cd96fbb5f94ef600fdfa9..9b977b14a39c46b87c90091b0806ba53b77a876b 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/ClaimType.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/ClaimType.java @@ -7,208 +7,172 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.io.conv; import java.util.Arrays; import java.util.Collections; import java.util.List; - /** - * - * A representation of the literals of the enumeration 'Claim Type', - * and utility methods for working with them. - * + * A representation of the literals of the enumeration 'Claim Type', and utility methods for working + * with them. + * * @see nl.esi.trace.datamodel.TracePackage#getClaimType() */ public enum ClaimType { - /** - * The 'Full' literal object. - * - * - * @see #FULL_VALUE - */ - FULL(0, "Full", "Full"), - - /** - * The 'Amount' literal object. - * - * - * @see #AMOUNT_VALUE - */ - AMOUNT(1, "Amount", "Amount"), - - /** - * The 'Amount Offset' literal object. - * - * - * @see #AMOUNT_OFFSET_VALUE - */ - AMOUNT_OFFSET(2, "AmountOffset", "AmountOffset"); - - /** - * The 'Full' literal value. - * - *

    - * If the meaning of 'Full' literal object isn't clear, - * there really should be more of a description here... - *

    - * - * @see #FULL - * @model name="Full" - */ - public static final int FULL_VALUE = 0; - - /** - * The 'Amount' literal value. - * - *

    - * If the meaning of 'Amount' literal object isn't clear, - * there really should be more of a description here... - *

    - * - * @see #AMOUNT - * @model name="Amount" - */ - public static final int AMOUNT_VALUE = 1; - - /** - * The 'Amount Offset' literal value. - * - *

    - * If the meaning of 'Amount Offset' literal object isn't clear, - * there really should be more of a description here... - *

    - * - * @see #AMOUNT_OFFSET - * @model name="AmountOffset" - */ - public static final int AMOUNT_OFFSET_VALUE = 2; - - /** - * An array of all the 'Claim Type' enumerators. - * - * - */ - private static final ClaimType[] VALUES_ARRAY = - new ClaimType[] { - FULL, - AMOUNT, - AMOUNT_OFFSET, - }; - - /** - * A public read-only list of all the 'Claim Type' enumerators. - * - * - */ - public static final List VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY)); - - /** - * Returns the 'Claim Type' literal with the specified literal value. - * - * - */ - public static ClaimType get(String literal) { - for (int i = 0; i < VALUES_ARRAY.length; ++i) { - ClaimType result = VALUES_ARRAY[i]; - if (result.toString().equals(literal)) { - return result; - } - } - return null; - } - - /** - * Returns the 'Claim Type' literal with the specified name. - * - * - */ - public static ClaimType getByName(String name) { - for (int i = 0; i < VALUES_ARRAY.length; ++i) { - ClaimType result = VALUES_ARRAY[i]; - if (result.getName().equals(name)) { - return result; - } - } - return null; - } - - /** - * Returns the 'Claim Type' literal with the specified integer value. - * - * - */ - public static ClaimType get(int value) { - switch (value) { - case FULL_VALUE: return FULL; - case AMOUNT_VALUE: return AMOUNT; - case AMOUNT_OFFSET_VALUE: return AMOUNT_OFFSET; - } - return null; - } - - /** - * - * - */ - private final int value; - - /** - * - * - */ - private final String name; - - /** - * - * - */ - private final String literal; - - /** - * Only this class can construct instances. - * - * - */ - private ClaimType(int value, String name, String literal) { - this.value = value; - this.name = name; - this.literal = literal; - } - - /** - * - * - */ - public int getValue() { - return value; - } - - /** - * - * - */ - public String getName() { - return name; - } - - /** - * - * - */ - public String getLiteral() { - return literal; - } - - /** - * Returns the literal value of the enumerator, which is its string representation. - * - * - */ - @Override - public String toString() { - return literal; - } - + /** + * The 'Full' literal object. + * + * @see #FULL_VALUE + */ + FULL(0, "Full", "Full"), + + /** + * The 'Amount' literal object. + * + * @see #AMOUNT_VALUE + */ + AMOUNT(1, "Amount", "Amount"), + + /** + * The 'Amount Offset' literal object. + * + * @see #AMOUNT_OFFSET_VALUE + */ + AMOUNT_OFFSET(2, "AmountOffset", "AmountOffset"); + + /** + * The 'Full' literal value. + *

    + * If the meaning of 'Full' literal object isn't clear, there really should be more of a description + * here... + *

    + * + * @see #FULL + * @model name="Full" + */ + public static final int FULL_VALUE = 0; + + /** + * The 'Amount' literal value. + *

    + * If the meaning of 'Amount' literal object isn't clear, there really should be more of a + * description here... + *

    + * + * @see #AMOUNT + * @model name="Amount" + */ + public static final int AMOUNT_VALUE = 1; + + /** + * The 'Amount Offset' literal value. + *

    + * If the meaning of 'Amount Offset' literal object isn't clear, there really should be more of a + * description here... + *

    + * + * @see #AMOUNT_OFFSET + * @model name="AmountOffset" + */ + public static final int AMOUNT_OFFSET_VALUE = 2; + + /** + * An array of all the 'Claim Type' enumerators. + */ + private static final ClaimType[] VALUES_ARRAY = new ClaimType[] {FULL, AMOUNT, AMOUNT_OFFSET}; + + /** + * A public read-only list of all the 'Claim Type' enumerators. + */ + public static final List VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY)); + + /** + * Returns the 'Claim Type' literal with the specified literal value. + */ + public static ClaimType get(String literal) { + for (int i = 0; i < VALUES_ARRAY.length; ++i) { + ClaimType result = VALUES_ARRAY[i]; + if (result.toString().equals(literal)) { + return result; + } + } + return null; + } + + /** + * Returns the 'Claim Type' literal with the specified name. + */ + public static ClaimType getByName(String name) { + for (int i = 0; i < VALUES_ARRAY.length; ++i) { + ClaimType result = VALUES_ARRAY[i]; + if (result.getName().equals(name)) { + return result; + } + } + return null; + } + + /** + * Returns the 'Claim Type' literal with the specified integer value. + */ + public static ClaimType get(int value) { + switch (value) { + case FULL_VALUE: + return FULL; + case AMOUNT_VALUE: + return AMOUNT; + case AMOUNT_OFFSET_VALUE: + return AMOUNT_OFFSET; + } + return null; + } + + /** + */ + private final int value; + + /** + */ + private final String name; + + /** + */ + private final String literal; + + /** + * Only this class can construct instances. + */ + private ClaimType(int value, String name, String literal) { + this.value = value; + this.name = name; + this.literal = literal; + } + + /** + */ + public int getValue() { + return value; + } + + /** + */ + public String getName() { + return name; + } + + /** + */ + public String getLiteral() { + return literal; + } + + /** + * Returns the literal value of the enumerator, which is its string representation. + */ + @Override + public String toString() { + return literal; + } } // ClaimType diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/Configuration.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/Configuration.java index 77b64ffeadfdd4fb44aaf1fac6881f2d4eeccb27..82996271cd5c2e4cac10495d862df6438d538ba7 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/Configuration.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/Configuration.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.io.conv; import java.awt.Color; @@ -16,24 +17,18 @@ import java.util.Iterator; import java.util.concurrent.TimeUnit; /** - * An implementation of the model object ' Configuration'. + * An implementation of the model object ' Configuration'. *

    * The following features are implemented: *

      - *
    • {@link nl.esi.trace.model.ganttchart.Configuration#getConfigurationVersion Configuration - * Version}
    • - *
    • {@link nl.esi.trace.model.ganttchart.Configuration#getConfigurationSource Configuration - * Source}
    • - *
    • {@link nl.esi.trace.model.ganttchart.Configuration#getConfigurationName Configuration - * Name}
    • + *
    • {@link nl.esi.trace.model.ganttchart.Configuration#getConfigurationVersion Configuration Version}
    • + *
    • {@link nl.esi.trace.model.ganttchart.Configuration#getConfigurationSource Configuration Source}
    • + *
    • {@link nl.esi.trace.model.ganttchart.Configuration#getConfigurationName Configuration Name}
    • *
    • {@link nl.esi.trace.model.ganttchart.Configuration#getConfigurationID Configuration ID}
    • *
    • {@link nl.esi.trace.model.ganttchart.Configuration#getTimeScaleShift Time Scale Shift}
    • *
    • {@link nl.esi.trace.model.ganttchart.Configuration#getTimeScaleUnit Time Scale Unit}
    • - *
    • {@link nl.esi.trace.model.ganttchart.Configuration#getTimeResolutionShift Time Resolution - * Shift}
    • - *
    • {@link nl.esi.trace.model.ganttchart.Configuration#getTimeDisplayFormat Time Display - * Format}
    • + *
    • {@link nl.esi.trace.model.ganttchart.Configuration#getTimeResolutionShift Time Resolution Shift}
    • + *
    • {@link nl.esi.trace.model.ganttchart.Configuration#getTimeDisplayFormat Time Display Format}
    • *
    • {@link nl.esi.trace.model.ganttchart.Configuration#getAttributes Attributes }
    • *
    • {@link nl.esi.trace.model.ganttchart.Configuration#getIdAttributeMap Id Attribute Map}
    • *
    • {@link nl.esi.trace.model.ganttchart.Configuration#getContexts Contexts }
    • @@ -42,35 +37,34 @@ import java.util.concurrent.TimeUnit; *

      */ public class Configuration extends Object { - /** - * The default value of the '{@link #getConfigurationVersion() Configuration Version}' attribute. - * - * + * The default value of the '{@link #getConfigurationVersion() Configuration Version}' attribute. + * * @see #getConfigurationVersion() */ protected static final String CONFIGURATION_VERSION_DEFAULT = null; /** - * The cached value of the '{@link #getConfigurationVersion() Configuration Version}' attribute. - * - * + * The cached value of the '{@link #getConfigurationVersion() Configuration Version}' attribute. + * * @see #getConfigurationVersion() */ protected String configurationVersion = CONFIGURATION_VERSION_DEFAULT; /** - * The default value of the '{@link #getConfigurationSource() Configuration Source}' attribute. - * - * + * The default value of the '{@link #getConfigurationSource() Configuration Source}' attribute. + * * @see #getConfigurationSource() */ protected static final String CONFIGURATION_SOURCE_DEFAULT = null; /** - * The cached value of the '{@link #getConfigurationSource() Configuration Source}' attribute. - * - * + * The cached value of the '{@link #getConfigurationSource() Configuration Source}' attribute. + * * @see #getConfigurationSource() */ protected String configurationSource = CONFIGURATION_SOURCE_DEFAULT; @@ -78,7 +72,7 @@ public class Configuration extends Object { /** * The default value of the '{@link #getConfigurationName() Configuration Name}' attribute. - * + * * @see #getConfigurationName() */ protected static final String CONFIGURATION_NAME_DEFAULT = null; @@ -86,71 +80,71 @@ public class Configuration extends Object { /** * The cached value of the '{@link #getConfigurationName() Configuration Name}' attribute. - * + * * @see #getConfigurationName() */ protected String configurationName = CONFIGURATION_NAME_DEFAULT; /** - * The default value of the '{@link #getConfigurationID() Configuration ID}' attribute. - * + * The default value of the '{@link #getConfigurationID() Configuration ID}' attribute. + * * @see #getConfigurationID() */ protected static final String CONFIGURATION_ID_DEFAULT = null; /** - * The cached value of the '{@link #getConfigurationID() Configuration ID}' attribute. - * + * The cached value of the '{@link #getConfigurationID() Configuration ID}' attribute. + * * @see #getConfigurationID() */ protected String configurationID = CONFIGURATION_ID_DEFAULT; /** - * The default value of the '{@link #getTimeScaleShift() Time Scale Shift}' attribute. - * + * The default value of the '{@link #getTimeScaleShift() Time Scale Shift}' attribute. + * * @see #getTimeScaleShift() */ protected static final int TIME_SCALE_SHIFT_DEFAULT = 0; /** - * The cached value of the '{@link #getTimeScaleShift() Time Scale Shift}' attribute. - * + * The cached value of the '{@link #getTimeScaleShift() Time Scale Shift}' attribute. + * * @see #getTimeScaleShift() */ protected int timeScaleShift = TIME_SCALE_SHIFT_DEFAULT; /** - * The default value of the '{@link #getTimeScaleUnit() Time Scale Unit}' attribute. - * + * The default value of the '{@link #getTimeScaleUnit() Time Scale Unit}' attribute. + * * @see #getTimeScaleUnit() */ protected static final String TIME_SCALE_UNIT_DEFAULT = "s"; /** - * The cached value of the '{@link #getTimeScaleUnit() Time Scale Unit}' attribute. - * + * The cached value of the '{@link #getTimeScaleUnit() Time Scale Unit}' attribute. + * + * * @see #getTimeScaleUnit() */ protected TimeUnit timeScaleUnit = TimeUnit.SECONDS; /** - * The default value of the '{@link #getTimeResolutionShift() Time Resolution Shift}' attribute. - * - * + * The default value of the '{@link #getTimeResolutionShift() Time Resolution Shift}' attribute. + * * @see #getTimeResolutionShift() */ protected static final int TIME_RESOLUTION_SHIFT_DEFAULT = 3; /** - * The cached value of the '{@link #getTimeResolutionShift() Time Resolution Shift}' attribute. - * - * + * The cached value of the '{@link #getTimeResolutionShift() Time Resolution Shift}' attribute. + * * @see #getTimeResolutionShift() */ protected int timeResolutionShift = TIME_RESOLUTION_SHIFT_DEFAULT; @@ -158,7 +152,7 @@ public class Configuration extends Object { /** * The default value of the '{@link #getTimeDisplayFormat() Time Display Format}' attribute. - * + * * @see #getTimeDisplayFormat() */ protected static final String TIME_DISPLAY_FORMAT_DEFAULT = "%.5g"; @@ -166,7 +160,7 @@ public class Configuration extends Object { /** * The cached value of the '{@link #getTimeDisplayFormat() Time Display Format}' attribute. - * + * * @see #getTimeDisplayFormat() */ protected String timeDisplayFormat = TIME_DISPLAY_FORMAT_DEFAULT; @@ -174,15 +168,15 @@ public class Configuration extends Object { /** * The cached value of the '{@link #getAttributes() Attributes}' containment reference list. - * + * * @see #getAttributes() */ protected ArrayList attributes; /** - * The cached value of the '{@link #getIdAttributeMap() Id Attribute Map}' map. - * + * The cached value of the '{@link #getIdAttributeMap() Id Attribute Map}' map. + * + * * @see #getIdAttributeMap() */ protected HashMap idAttributeMap; @@ -192,15 +186,15 @@ public class Configuration extends Object { /** * The cached value of the '{@link #getContexts() Contexts}' containment reference list. - * + * * @see #getContexts() */ protected ArrayList contexts; /** - * The cached value of the '{@link #getIdContextMap() Id Context Map}' map. - * + * The cached value of the '{@link #getIdContextMap() Id Context Map}' map. + * * @see #getIdContextMap() */ protected HashMap idContextMap; @@ -318,7 +312,7 @@ public class Configuration extends Object { /** * - * + * * @generated */ public void setTimeResolutionShift(int newTimeResolutionShift) { @@ -436,7 +430,7 @@ public class Configuration extends Object { * */ public Attribute getAttribute(Integer aId) { - return (Attribute) getIdAttributeMap().get(aId); + return (Attribute)getIdAttributeMap().get(aId); } /** @@ -459,7 +453,7 @@ public class Configuration extends Object { * */ public Context getContext(Integer aId) { - return (Context) getIdContextMap().get(aId); + return (Context)getIdContextMap().get(aId); } public boolean getScaleClaimsInActivityViewWithResourceAmount() { @@ -488,19 +482,18 @@ public class Configuration extends Object { result.append(" no attributes\n"); } else { for (Iterator ia = attributes.iterator(); ia.hasNext();) { - result.append(" attribute: " + ((Attribute) ia.next()).toString() + "\n"); + result.append(" attribute: " + ia.next().toString() + "\n"); } } if (contexts == null) { result.append(" no contexts\n"); } else { for (Iterator ic = contexts.iterator(); ic.hasNext();) { - Context cc = (Context) ic.next(); + Context cc = ic.next(); result.append(" context : " + cc.toString()); } } return result.toString(); } - } // Configuration diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/Context.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/Context.java index f2758532fc553ddb79f48953810ebeb488708a34..463aca5335fcd3eb36d5917ac5622bc59aac9238 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/Context.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/Context.java @@ -7,135 +7,114 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.io.conv; import java.util.ArrayList; import java.util.Iterator; /** - * * An implementation of the model object 'Context'. - * *

      * The following features are implemented: *

        - *
      • {@link nl.esi.trace.model.ganttchart.Context#getContextID Context ID}
      • - *
      • {@link nl.esi.trace.model.ganttchart.Context#getContextName Context Name}
      • - *
      • {@link nl.esi.trace.model.ganttchart.Context#getAttributes Attributes}
      • + *
      • {@link nl.esi.trace.model.ganttchart.Context#getContextID Context ID}
      • + *
      • {@link nl.esi.trace.model.ganttchart.Context#getContextName Context Name}
      • + *
      • {@link nl.esi.trace.model.ganttchart.Context#getAttributes Attributes}
      • *
      *

      * * @generated */ public class Context extends Object { - /** - * The default value of the '{@link #getContextID() Context ID}' attribute. - * - * - * @see #getContextID() - */ - protected static final int CONTEXT_ID_DEFAULT = 0; - - /** - * The cached value of the '{@link #getContextID() Context ID}' attribute. - * - * - * @see #getContextID() - */ - protected int contextID = CONTEXT_ID_DEFAULT; + /** + * The default value of the '{@link #getContextID() Context ID}' attribute. + * + * @see #getContextID() + */ + protected static final int CONTEXT_ID_DEFAULT = 0; - /** - * The default value of the '{@link #getContextName() Context Name}' attribute. - * - * - * @see #getContextName() - */ - protected static final String CONTEXT_NAME_DEFAULT = null; + /** + * The cached value of the '{@link #getContextID() Context ID}' attribute. + * + * @see #getContextID() + */ + protected int contextID = CONTEXT_ID_DEFAULT; - /** - * The cached value of the '{@link #getContextName() Context Name}' attribute. - * - * - * @see #getContextName() - */ - protected String contextName = CONTEXT_NAME_DEFAULT; + /** + * The default value of the '{@link #getContextName() Context Name}' attribute. + * + * @see #getContextName() + */ + protected static final String CONTEXT_NAME_DEFAULT = null; - /** - * The cached value of the '{@link #getAttributes() Attributes}' reference list. - * - * - * @see #getAttributes() - */ - protected ArrayList attributes; + /** + * The cached value of the '{@link #getContextName() Context Name}' attribute. + * + * @see #getContextName() + */ + protected String contextName = CONTEXT_NAME_DEFAULT; - /** - * - * - */ - public Context() { - super(); - } + /** + * The cached value of the '{@link #getAttributes() Attributes}' reference list. + * + * @see #getAttributes() + */ + protected ArrayList attributes; - /** - * - * - */ - public int getContextID() { - return contextID; - } + /** + */ + public Context() { + super(); + } - /** - * - * - */ - public void setContextID(int newContextID) { - contextID = newContextID; - } + /** + */ + public int getContextID() { + return contextID; + } - /** - * - * - */ - public String getContextName() { - return contextName; - } + /** + */ + public void setContextID(int newContextID) { + contextID = newContextID; + } - /** - * - * - */ - public void setContextName(String newContextName) { - contextName = newContextName; - } + /** + */ + public String getContextName() { + return contextName; + } - /** - * - * - */ - public ArrayList getAttributes() { - if (attributes == null) { - attributes = new ArrayList(); - } - return attributes; - } + /** + */ + public void setContextName(String newContextName) { + contextName = newContextName; + } - /** - * - * - */ - @Override - public String toString() { - StringBuffer result = new StringBuffer(); - result.append("[Context ID: " + contextID + ", Context Name: " + contextName + " attributeIDs: "); - if (attributes == null) { - result.append("null"); - } else { - for (Iterator ia = attributes.iterator(); ia.hasNext();) { - result.append(((Attribute)ia.next()).getAttributeID() + (ia.hasNext() ? ", " : "")); - } - } - result.append("]\n"); - return result.toString(); - } + /** + */ + public ArrayList getAttributes() { + if (attributes == null) { + attributes = new ArrayList(); + } + return attributes; + } + /** + */ + @Override + public String toString() { + StringBuffer result = new StringBuffer(); + result.append("[Context ID: " + contextID + ", Context Name: " + contextName + " attributeIDs: "); + if (attributes == null) { + result.append("null"); + } else { + for (Iterator ia = attributes.iterator(); ia.hasNext();) { + result.append(ia.next().getAttributeID() + (ia.hasNext() ? ", " : "")); + } + } + result.append("]\n"); + return result.toString(); + } } // Context diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/DependencyType.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/DependencyType.java index 0f15bec858524deb02a46641f5beed09a8f6f80d..b4bdde23a95bd55f207cdeb16f0271d74e3882e3 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/DependencyType.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/DependencyType.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.io.conv; import java.util.Arrays; @@ -14,223 +15,186 @@ import java.util.Collections; import java.util.List; /** - * - * A representation of the literals of the enumeration 'Dependency Type', - * and utility methods for working with them. - * + * A representation of the literals of the enumeration 'Dependency Type', and utility methods for + * working with them. + * * @see nl.esi.trace.datamodel.TracePackage#getDependencyType() */ public enum DependencyType { - /** - * The 'Source Stop2 Sink Start' literal object. - * - * - * @see #SOURCE_STOP2_SINK_START_VALUE - */ - SOURCE_STOP2_SINK_START(0, "SourceStop2SinkStart", "SourceStop2SinkStart"), - - /** - * The 'Source Stop2 Sink Stop' literal object. - * - * - * @see #SOURCE_STOP2_SINK_STOP_VALUE - */ - SOURCE_STOP2_SINK_STOP(1, "SourceStop2SinkStop", "SourceStop2SinkStop"), - - /** - * The 'Source Start2 Sink Start' literal object. - * - * - * @see #SOURCE_START2_SINK_START_VALUE - */ - SOURCE_START2_SINK_START(2, "SourceStart2SinkStart", "SourceStart2SinkStart"), - - /** - * The 'Source Start2 Sink Stop' literal object. - * - * - * @see #SOURCE_START2_SINK_STOP_VALUE - */ - SOURCE_START2_SINK_STOP(3, "SourceStart2SinkStop", "SourceStart2SinkStop"); - - /** - * The 'Source Stop2 Sink Start' literal value. - * - *

      - * If the meaning of 'Source Stop2 Sink Start' literal object isn't clear, - * there really should be more of a description here... - *

      - * - * @see #SOURCE_STOP2_SINK_START - * @model name="SourceStop2SinkStart" - */ - public static final int SOURCE_STOP2_SINK_START_VALUE = 0; - - /** - * The 'Source Stop2 Sink Stop' literal value. - * - *

      - * If the meaning of 'Source Stop2 Sink Stop' literal object isn't clear, - * there really should be more of a description here... - *

      - * - * @see #SOURCE_STOP2_SINK_STOP - * @model name="SourceStop2SinkStop" - */ - public static final int SOURCE_STOP2_SINK_STOP_VALUE = 1; - - /** - * The 'Source Start2 Sink Start' literal value. - * - *

      - * If the meaning of 'Source Start2 Sink Start' literal object isn't clear, - * there really should be more of a description here... - *

      - * - * @see #SOURCE_START2_SINK_START - * @model name="SourceStart2SinkStart" - */ - public static final int SOURCE_START2_SINK_START_VALUE = 2; - - /** - * The 'Source Start2 Sink Stop' literal value. - * - *

      - * If the meaning of 'Source Start2 Sink Stop' literal object isn't clear, - * there really should be more of a description here... - *

      - * - * @see #SOURCE_START2_SINK_STOP - * @model name="SourceStart2SinkStop" - */ - public static final int SOURCE_START2_SINK_STOP_VALUE = 3; - - /** - * An array of all the 'Dependency Type' enumerators. - * - * - */ - private static final DependencyType[] VALUES_ARRAY = - new DependencyType[] { - SOURCE_STOP2_SINK_START, - SOURCE_STOP2_SINK_STOP, - SOURCE_START2_SINK_START, - SOURCE_START2_SINK_STOP, - }; - - /** - * A public read-only list of all the 'Dependency Type' enumerators. - * - * - */ - public static final List VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY)); - - /** - * Returns the 'Dependency Type' literal with the specified literal value. - * - * - */ - public static DependencyType get(String literal) { - for (int i = 0; i < VALUES_ARRAY.length; ++i) { - DependencyType result = VALUES_ARRAY[i]; - if (result.toString().equals(literal)) { - return result; - } - } - return null; - } - - /** - * Returns the 'Dependency Type' literal with the specified name. - * - * - */ - public static DependencyType getByName(String name) { - for (int i = 0; i < VALUES_ARRAY.length; ++i) { - DependencyType result = VALUES_ARRAY[i]; - if (result.getName().equals(name)) { - return result; - } - } - return null; - } - - /** - * Returns the 'Dependency Type' literal with the specified integer value. - * - * - */ - public static DependencyType get(int value) { - switch (value) { - case SOURCE_STOP2_SINK_START_VALUE: return SOURCE_STOP2_SINK_START; - case SOURCE_STOP2_SINK_STOP_VALUE: return SOURCE_STOP2_SINK_STOP; - case SOURCE_START2_SINK_START_VALUE: return SOURCE_START2_SINK_START; - case SOURCE_START2_SINK_STOP_VALUE: return SOURCE_START2_SINK_STOP; - } - return null; - } - - /** - * - * - */ - private final int value; - - /** - * - * - */ - private final String name; - - /** - * - * - */ - private final String literal; - - /** - * Only this class can construct instances. - * - * - */ - private DependencyType(int value, String name, String literal) { - this.value = value; - this.name = name; - this.literal = literal; - } - - /** - * - * - */ - public int getValue() { - return value; - } - - /** - * - * - */ - public String getName() { - return name; - } - - /** - * - * - */ - public String getLiteral() { - return literal; - } - - /** - * Returns the literal value of the enumerator, which is its string representation. - * - * - */ - @Override - public String toString() { - return literal; - } - + /** + * The 'Source Stop2 Sink Start' literal object. + * + * @see #SOURCE_STOP2_SINK_START_VALUE + */ + SOURCE_STOP2_SINK_START(0, "SourceStop2SinkStart", "SourceStop2SinkStart"), + + /** + * The 'Source Stop2 Sink Stop' literal object. + * + * @see #SOURCE_STOP2_SINK_STOP_VALUE + */ + SOURCE_STOP2_SINK_STOP(1, "SourceStop2SinkStop", "SourceStop2SinkStop"), + + /** + * The 'Source Start2 Sink Start' literal object. + * + * @see #SOURCE_START2_SINK_START_VALUE + */ + SOURCE_START2_SINK_START(2, "SourceStart2SinkStart", "SourceStart2SinkStart"), + + /** + * The 'Source Start2 Sink Stop' literal object. + * + * @see #SOURCE_START2_SINK_STOP_VALUE + */ + SOURCE_START2_SINK_STOP(3, "SourceStart2SinkStop", "SourceStart2SinkStop"); + + /** + * The 'Source Stop2 Sink Start' literal value. + *

      + * If the meaning of 'Source Stop2 Sink Start' literal object isn't clear, there really should be + * more of a description here... + *

      + * + * @see #SOURCE_STOP2_SINK_START + * @model name="SourceStop2SinkStart" + */ + public static final int SOURCE_STOP2_SINK_START_VALUE = 0; + + /** + * The 'Source Stop2 Sink Stop' literal value. + *

      + * If the meaning of 'Source Stop2 Sink Stop' literal object isn't clear, there really should be + * more of a description here... + *

      + * + * @see #SOURCE_STOP2_SINK_STOP + * @model name="SourceStop2SinkStop" + */ + public static final int SOURCE_STOP2_SINK_STOP_VALUE = 1; + + /** + * The 'Source Start2 Sink Start' literal value. + *

      + * If the meaning of 'Source Start2 Sink Start' literal object isn't clear, there really should be + * more of a description here... + *

      + * + * @see #SOURCE_START2_SINK_START + * @model name="SourceStart2SinkStart" + */ + public static final int SOURCE_START2_SINK_START_VALUE = 2; + + /** + * The 'Source Start2 Sink Stop' literal value. + *

      + * If the meaning of 'Source Start2 Sink Stop' literal object isn't clear, there really should be + * more of a description here... + *

      + * + * @see #SOURCE_START2_SINK_STOP + * @model name="SourceStart2SinkStop" + */ + public static final int SOURCE_START2_SINK_STOP_VALUE = 3; + + /** + * An array of all the 'Dependency Type' enumerators. + */ + private static final DependencyType[] VALUES_ARRAY = new DependencyType[] {SOURCE_STOP2_SINK_START, + SOURCE_STOP2_SINK_STOP, SOURCE_START2_SINK_START, SOURCE_START2_SINK_STOP}; + + /** + * A public read-only list of all the 'Dependency Type' enumerators. + */ + public static final List VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY)); + + /** + * Returns the 'Dependency Type' literal with the specified literal value. + */ + public static DependencyType get(String literal) { + for (int i = 0; i < VALUES_ARRAY.length; ++i) { + DependencyType result = VALUES_ARRAY[i]; + if (result.toString().equals(literal)) { + return result; + } + } + return null; + } + + /** + * Returns the 'Dependency Type' literal with the specified name. + */ + public static DependencyType getByName(String name) { + for (int i = 0; i < VALUES_ARRAY.length; ++i) { + DependencyType result = VALUES_ARRAY[i]; + if (result.getName().equals(name)) { + return result; + } + } + return null; + } + + /** + * Returns the 'Dependency Type' literal with the specified integer value. + */ + public static DependencyType get(int value) { + switch (value) { + case SOURCE_STOP2_SINK_START_VALUE: + return SOURCE_STOP2_SINK_START; + case SOURCE_STOP2_SINK_STOP_VALUE: + return SOURCE_STOP2_SINK_STOP; + case SOURCE_START2_SINK_START_VALUE: + return SOURCE_START2_SINK_START; + case SOURCE_START2_SINK_STOP_VALUE: + return SOURCE_START2_SINK_STOP; + } + return null; + } + + /** + */ + private final int value; + + /** + */ + private final String name; + + /** + */ + private final String literal; + + /** + * Only this class can construct instances. + */ + private DependencyType(int value, String name, String literal) { + this.value = value; + this.name = name; + this.literal = literal; + } + + /** + */ + public int getValue() { + return value; + } + + /** + */ + public String getName() { + return name; + } + + /** + */ + public String getLiteral() { + return literal; + } + + /** + * Returns the literal value of the enumerator, which is its string representation. + */ + @Override + public String toString() { + return literal; + } } // DependencyType diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/ESIFormatConfigurationParser.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/ESIFormatConfigurationParser.java index 811c6af8d15bc6f5f76b60651f00a7a90b206941..7f59d06400aba70206b3444485ae65ad8ffff5cb 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/ESIFormatConfigurationParser.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/ESIFormatConfigurationParser.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.io.conv; import java.awt.Color; @@ -17,7 +18,6 @@ import java.io.IOException; import java.io.InputStreamReader; public class ESIFormatConfigurationParser extends ESIFormatParser { - private static final String FORMAT_VERSION = "V0.1"; private static final int MAX_TIMESCALESHIFT = 99; @@ -50,36 +50,31 @@ public class ESIFormatConfigurationParser extends ESIFormatParser { /** * Parses a Trace V0.x configuration file. - * - * @param configFile - * @return + * + * @param configFile The config file to parse + * @return The parsed config * @throws IOException * @throws ParserException */ public Configuration parseTraceV0config(File configFile) throws IOException, ParserException { Configuration config = new Configuration(); config.setConfigurationSource(configFile.getAbsolutePath()); - FileInputStream in = new FileInputStream(configFile); - Parse(configFile.getAbsolutePath(), in, config); - in.close(); + try (FileInputStream in = new FileInputStream(configFile)) { + parse(configFile.getAbsolutePath(), in, config); + } return config; } - private void Parse(String src, FileInputStream in, Configuration aConfig) - throws IOException, ParserException { + private void parse(String src, FileInputStream in, Configuration aConfig) throws IOException, ParserException { int n_CONFIGURATIONVERSION = 0; int n_CONFIGURATIONNAME = 0; int n_CONFIGURATIONID = 0; int n_TIMESCALESHIFT = 0; int n_TIMESCALEUNIT = 0; int n_TIMEDISPLAYFORMAT = 0; - int n_ATTRIBUTE = 0; - int n_CONTEXT = 0; - int n_QUANTITY = 0; int n_SCALE_CLAIMS = 0; - BufferedReader reader = new BufferedReader(new InputStreamReader(in)); - try { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) { String line = null; int linenr = 0; @@ -88,20 +83,18 @@ public class ESIFormatConfigurationParser extends ESIFormatParser { String[] tok = line.split(SEPARATOR, -1); if (tok.length >= 2) { switch (tok[0]) { - case CONFIGURATIONFORMATVERSION_TAG: - System.err.println(CONFIGURATIONFORMATVERSION_TAG + " is deprecated; use " - + CONFIGURATIONVERSION_TAG + " instead"); - case CONFIGURATIONVERSION_TAG: - aConfig.setConfigurationVersion(tok[1]); - if (!tok[1].equalsIgnoreCase(FORMAT_VERSION)) { - throw new ParserException("Configuration version not supported " + tok[1], src, - linenr); - } - n_CONFIGURATIONVERSION++; - break; - default: - throw new ParserException("Configuration version missing as first element", src, - linenr); + case CONFIGURATIONFORMATVERSION_TAG: + System.err.println(CONFIGURATIONFORMATVERSION_TAG + " is deprecated; use " + + CONFIGURATIONVERSION_TAG + " instead"); + case CONFIGURATIONVERSION_TAG: + aConfig.setConfigurationVersion(tok[1]); + if (!tok[1].equalsIgnoreCase(FORMAT_VERSION)) { + throw new ParserException("Configuration version not supported " + tok[1], src, linenr); + } + n_CONFIGURATIONVERSION++; + break; + default: + throw new ParserException("Configuration version missing as first element", src, linenr); } } } @@ -112,236 +105,226 @@ public class ESIFormatConfigurationParser extends ESIFormatParser { if (tok.length >= 2) { int index; switch (tok[0]) { - - case CONFIGURATIONNAME_TAG: - if (n_CONFIGURATIONNAME > 0) { - throw new ParserException("Configuration name allready declared as " - + aConfig.getConfigurationName(), src, linenr); - } - aConfig.setConfigurationName(tok[1]); - n_CONFIGURATIONNAME++; - break; - - case CONFIGURATIONID_TAG: - if (n_CONFIGURATIONID > 0) { - throw new ParserException( - "Configuration ID allready declared as " + aConfig.getConfigurationID(), - src, linenr); - } - aConfig.setConfigurationID(tok[1]); - n_CONFIGURATIONID++; - break; - - case TIMESCALESHIFT_TAG: - if (n_TIMESCALESHIFT > 0) { - throw new ParserException( - "TimeScaleShift allready declared as " + aConfig.getTimeScaleShift(), src, - linenr); - } - try { - int timeScaleShift = Integer.parseInt(tok[1]); - if (Math.abs(timeScaleShift) > MAX_TIMESCALESHIFT) { - throw new ParserException("TimeScaleShift to large " + tok[1], src, linenr); + case CONFIGURATIONNAME_TAG: + if (n_CONFIGURATIONNAME > 0) { + throw new ParserException( + "Configuration name allready declared as " + aConfig.getConfigurationName(), + src, linenr); } - aConfig.setTimeScaleShift(timeScaleShift); - n_TIMESCALESHIFT++; - } catch (NumberFormatException e) { - throw new ParserException("TimeScaleShift has illegal value " + tok[1], src, - linenr); - } - break; - - case TIMESCALEUNIT_TAG: - if (n_TIMESCALEUNIT > 0) { - throw new ParserException( - "TimeScaleUnit allready declared as " + aConfig.getTimeScaleUnit(), src, - linenr); - } - if (!aConfig.setTimeScaleUnit(tok[1])) { - throw new ParserException( - "TimeScaleUnit not valid: expected a java.util.concurrent.TimeUnit string " - + aConfig.getTimeScaleUnit(), - src, linenr); - } - n_TIMESCALEUNIT++; - break; - - case TIMEPRESENTATIONFORMAT_TAG: - System.err.println(TIMEPRESENTATIONFORMAT_TAG + " is deprecated; use " - + TIMEDISPLAYFORMAT_TAG + " instead"); - case TIMEDISPLAYFORMAT_TAG: - if (n_TIMEDISPLAYFORMAT > 0) { - throw new ParserException("TimeDisplayFormat allready declared as " - + aConfig.getTimeDisplayFormat(), src, linenr); - } - aConfig.setTimeDisplayFormat(tok[1]); - n_TIMEDISPLAYFORMAT++; - try { - // Ignores the return value, just used to check if it throws an exception to - // verify the time display format is valid - String.format(aConfig.getTimeDisplayFormat(), 0.0); - } catch (Exception e) { - throw new ParserException("TimeDisplayFormat is illegal at: " + e.getMessage() - + " in " + aConfig.getTimeDisplayFormat(), src, linenr); - } - - break; - - case SCALE_CLAIMS_IN_ACTIVITY_VIEW_TAG: - if (n_SCALE_CLAIMS > 0) { - throw new ParserException( - SCALE_CLAIMS_IN_ACTIVITY_VIEW_TAG + " allready declared as " - + aConfig.getScaleClaimsInActivityViewWithResourceAmount(), - src, linenr); - } - aConfig.setScaleClaimsInActivityViewWithResourceAmount(Boolean.parseBoolean(tok[1])); - n_SCALE_CLAIMS++; - break; - - case ATTRIBUTE_TAG: - int aid; - index = 1; - try { - aid = Integer.parseInt(tok[index]); - if (aConfig.getIdAttributeMap().containsKey(aid)) { - throw new ParserException("Attribute(ID) already exists " + tok[index], src, + aConfig.setConfigurationName(tok[1]); + n_CONFIGURATIONNAME++; + break; + + case CONFIGURATIONID_TAG: + if (n_CONFIGURATIONID > 0) { + throw new ParserException( + "Configuration ID allready declared as " + aConfig.getConfigurationID(), src, linenr); } - Attribute attribute = new Attribute(); + aConfig.setConfigurationID(tok[1]); + n_CONFIGURATIONID++; + break; - if (tok.length <= ++index) { + case TIMESCALESHIFT_TAG: + if (n_TIMESCALESHIFT > 0) { throw new ParserException( - "Required Attribute name expected for Attribute id " + aid, src, + "TimeScaleShift allready declared as " + aConfig.getTimeScaleShift(), src, linenr); } - attribute.setAttributeName(tok[index]); + try { + int timeScaleShift = Integer.parseInt(tok[1]); + if (Math.abs(timeScaleShift) > MAX_TIMESCALESHIFT) { + throw new ParserException("TimeScaleShift to large " + tok[1], src, linenr); + } + aConfig.setTimeScaleShift(timeScaleShift); + n_TIMESCALESHIFT++; + } catch (NumberFormatException e) { + throw new ParserException("TimeScaleShift has illegal value " + tok[1], src, linenr); + } + break; - if (tok.length <= ++index) { + case TIMESCALEUNIT_TAG: + if (n_TIMESCALEUNIT > 0) { + throw new ParserException( + "TimeScaleUnit allready declared as " + aConfig.getTimeScaleUnit(), src, + linenr); + } + if (!aConfig.setTimeScaleUnit(tok[1])) { + throw new ParserException( + "TimeScaleUnit not valid: expected a java.util.concurrent.TimeUnit string " + + aConfig.getTimeScaleUnit(), + src, linenr); + } + n_TIMESCALEUNIT++; + break; + + case TIMEPRESENTATIONFORMAT_TAG: + System.err.println(TIMEPRESENTATIONFORMAT_TAG + " is deprecated; use " + + TIMEDISPLAYFORMAT_TAG + " instead"); + case TIMEDISPLAYFORMAT_TAG: + if (n_TIMEDISPLAYFORMAT > 0) { throw new ParserException( - "Required AttributeValue type expected for Attribute id " + aid, src, + "TimeDisplayFormat allready declared as " + aConfig.getTimeDisplayFormat(), src, linenr); } - AttributeValueType valuetype = AttributeValueType.get(tok[index]); - if (valuetype == null) { - throw new ParserException("Value type " + tok[index] - + " is not recognized for Attribute id " + aid, src, linenr); + aConfig.setTimeDisplayFormat(tok[1]); + n_TIMEDISPLAYFORMAT++; + try { + // Ignores the return value, just used to check if it throws an exception to + // verify the time display format is valid + String.format(aConfig.getTimeDisplayFormat(), 0.0); + } catch (Exception e) { + throw new ParserException("TimeDisplayFormat is illegal at: " + e.getMessage() + " in " + + aConfig.getTimeDisplayFormat(), src, linenr); } - if (valuetype != AttributeValueType.STRING) { + + break; + + case SCALE_CLAIMS_IN_ACTIVITY_VIEW_TAG: + if (n_SCALE_CLAIMS > 0) { throw new ParserException( - "Only AttributeValue type String is supported for Attribute id " - + aid, + SCALE_CLAIMS_IN_ACTIVITY_VIEW_TAG + " allready declared as " + + aConfig.getScaleClaimsInActivityViewWithResourceAmount(), src, linenr); } - attribute.setAttributeValueType(valuetype); + aConfig.setScaleClaimsInActivityViewWithResourceAmount(Boolean.parseBoolean(tok[1])); + n_SCALE_CLAIMS++; + break; + + case ATTRIBUTE_TAG: + int aid; + index = 1; + try { + aid = Integer.parseInt(tok[index]); + if (aConfig.getIdAttributeMap().containsKey(aid)) { + throw new ParserException("Attribute(ID) already exists " + tok[index], src, + linenr); + } + Attribute attribute = new Attribute(); - for (++index; index < tok.length; index++) { - AttributeUsageType usagetype = AttributeUsageType.get(tok[index]); - if (usagetype == null) { + if (tok.length <= ++index) { + throw new ParserException( + "Required Attribute name expected for Attribute id " + aid, src, linenr); + } + attribute.setAttributeName(tok[index]); + + if (tok.length <= ++index) { + throw new ParserException( + "Required AttributeValue type expected for Attribute id " + aid, src, + linenr); + } + AttributeValueType valuetype = AttributeValueType.get(tok[index]); + if (valuetype == null) { + throw new ParserException( + "Value type " + tok[index] + " is not recognized for Attribute id " + aid, + src, linenr); + } + if (valuetype != AttributeValueType.STRING) { throw new ParserException( - "Usage type " + tok[index] - + " is not recognized for Attribute id " + aid, + "Only AttributeValue type String is supported for Attribute id " + aid, src, + linenr); + } + attribute.setAttributeValueType(valuetype); + + for (++index; index < tok.length; index++) { + AttributeUsageType usagetype = AttributeUsageType.get(tok[index]); + if (usagetype == null) { + throw new ParserException("Usage type " + tok[index] + + " is not recognized for Attribute id " + aid, src, linenr); + } + if (!attribute.getAttributeUsages().contains(usagetype)) { + attribute.getAttributeUsages().add(usagetype); + } + } + aConfig.addAttribute(aid, attribute); + } catch (NumberFormatException e) { + throw new ParserException("AttributeID has illegal value " + tok[index], src, linenr); + } + break; + + case CONTEXT_TAG: + index = 1; + int cid; + try { + cid = Integer.parseInt(tok[index]); + if (aConfig.getIdContextMap().containsKey(cid)) { + throw new ParserException("Context(ID) already exists " + tok[index], src, linenr); + } + Context context = new Context(); + + if (tok.length <= ++index) { + throw new ParserException("Required Context Name expected for Context id " + cid, src, linenr); } - if (!attribute.getAttributeUsages().contains(usagetype)) { - attribute.getAttributeUsages().add(usagetype); + context.setContextName(tok[index]); + + for (++index; index < tok.length; index++) { + try { + aid = Integer.parseInt(tok[index]); + + if (!aConfig.getIdAttributeMap().containsKey(aid)) { + throw new ParserException( + "Referenced Attribute(ID) does not exist " + tok[index], src, + linenr); + } + context.getAttributes().add(aConfig.getAttribute(aid)); + } catch (NumberFormatException e) { + throw new ParserException("Attribute reference has illegal value " + tok[index], + src, linenr); + } } + aConfig.addContext(cid, context); + } catch (NumberFormatException e) { + throw new ParserException("ContextID has illegal value " + tok[index], src, linenr); } - aConfig.addAttribute(aid, attribute); - n_ATTRIBUTE++; - } catch (NumberFormatException e) { - throw new ParserException("AttributeID has illegal value " + tok[index], src, - linenr); - } - break; - - case CONTEXT_TAG: - index = 1; - int cid; - try { - cid = Integer.parseInt(tok[index]); - if (aConfig.getIdContextMap().containsKey(cid)) { - throw new ParserException("Context(ID) already exists " + tok[index], src, + break; + + case COLORDEF_TAG: + index = 1; + if (tok.length <= index) { + throw new ParserException("Required ColorName expected for ColorDefinition", src, linenr); } - Context context = new Context(); - + String colorDefName = tok[index]; if (tok.length <= ++index) { - throw new ParserException( - "Required Context Name expected for Context id " + cid, src, linenr); + throw new ParserException("Required Color expected for ColorDefinition", src, linenr); } - context.setContextName(tok[index]); + Color colorDefColor = null; + try { + colorDefColor = Color.decode(tok[index]); + } catch (NumberFormatException e) { + throw new ParserException("Could not parse " + tok[index] + " as valid color", src, + linenr); + } + aConfig.getColorDefinitionMap().put(colorDefName, colorDefColor); + break; - for (++index; index < tok.length; index++) { - try { - aid = Integer.parseInt(tok[index]); + case QUANTITY_TAG: + throw new ParserException("Quantity not supported by the conversion", src, linenr); - if (!aConfig.getIdAttributeMap().containsKey(aid)) { - throw new ParserException( - "Referenced Attribute(ID) does not exist " + tok[index], src, - linenr); - } - context.getAttributes().add(aConfig.getAttribute(aid)); - } catch (NumberFormatException e) { - throw new ParserException( - "Attribute reference has illegal value " + tok[index], src, - linenr); - } + case FILTERINGVALUES_TAG: + index = 1; + int afvid = Integer.parseInt(tok[index]); + + if (!aConfig.getIdAttributeMap().containsKey(afvid)) { + throw new ParserException("Referenced Attribute(ID) does not exist " + tok[index], src, + linenr); } - aConfig.addContext(cid, context); - n_CONTEXT++; - } catch (NumberFormatException e) { - throw new ParserException("ContextID has illegal value " + tok[index], src, - linenr); - } - break; - - case COLORDEF_TAG: - index = 1; - if (tok.length <= index) { - throw new ParserException("Required ColorName expected for ColorDefinition", src, - linenr); - } - String colorDefName = tok[index]; - if (tok.length <= ++index) { - throw new ParserException("Required Color expected for ColorDefinition", src, - linenr); - } - Color colorDefColor = null; - try { - colorDefColor = Color.decode(tok[index]); - } catch (NumberFormatException e) { - throw new ParserException("Could not parse " + tok[index] + " as valid color", - src, linenr); - } - aConfig.getColorDefinitionMap().put(colorDefName, colorDefColor); - break; - - case QUANTITY_TAG: - throw new ParserException("Quantity not supported by the conversion", src, linenr); - - case FILTERINGVALUES_TAG: - index = 1; - int afvid = Integer.parseInt(tok[index]); - - if (!aConfig.getIdAttributeMap().containsKey(afvid)) { - throw new ParserException("Referenced Attribute(ID) does not exist " + tok[index], - src, linenr); - } - Attribute attribute = aConfig.getAttribute(afvid); - - if (tok.length <= ++index) { - throw new ParserException( - "At least 1 filtering value expected for FilteringValues", src, linenr); - } - - while (index < tok.length) { - String filteringValue = tok[index++]; - attribute.getAttributeFilteringValues().add(filteringValue.toCharArray()); - } - break; - - default: - throw new ParserException("Token not recognised " + tok[0], src, linenr); + Attribute attribute = aConfig.getAttribute(afvid); + + if (tok.length <= ++index) { + throw new ParserException("At least 1 filtering value expected for FilteringValues", + src, linenr); + } + + while (index < tok.length) { + String filteringValue = tok[index++]; + attribute.getAttributeFilteringValues().add(filteringValue.toCharArray()); + } + break; + + default: + throw new ParserException("Token not recognised " + tok[0], src, linenr); } } else { if (!tok[0].isEmpty()) { @@ -362,8 +345,6 @@ public class ESIFormatConfigurationParser extends ESIFormatParser { if (n_TIMEDISPLAYFORMAT == 0) { throw new ParserException("Missing required " + TIMEDISPLAYFORMAT_TAG, src, 0); } - } finally { - reader.close(); } return; } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/ESIFormatParser.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/ESIFormatParser.java index 8e5567b4cc5b577d31e9cf8a5beca355e3e7fbd1..cd26ede24b64aeab24a63dbd957f3f1d4eb04377 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/ESIFormatParser.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/ESIFormatParser.java @@ -7,15 +7,16 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.io.conv; public abstract class ESIFormatParser { + protected static final String CONFIGURATIONID_TAG = "ConfigurationID"; + + protected static final String CONFIGURATION_SOURCE = "ConfigurationSource"; + // Fixed values for parsing + protected static final String SEPARATOR = "\t"; - protected static final String CONFIGURATIONID_TAG = "ConfigurationID"; - - protected static final String CONFIGURATION_SOURCE = "ConfigurationSource"; - // Fixed values for parsing - protected static final String SEPARATOR = "\t"; - protected static final char TERMINATOR = '\n'; + protected static final char TERMINATOR = '\n'; } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/ESIFormatTraceParser.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/ESIFormatTraceParser.java index 6a5fb6b8bfa85b83e21078d133a91c5e9c2ce7a5..59057d19faa11f6de95dac1c03ed887ce5274731 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/ESIFormatTraceParser.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/ESIFormatTraceParser.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.io.conv; import java.io.BufferedReader; @@ -81,20 +82,20 @@ public class ESIFormatTraceParser extends ESIFormatParser { /** * Parses an original trace file (which consists of a configuration file and a data file) - * - * @param traceFile - * @param aConfig - * @return + * + * @param traceFile The trace file to parse + * @param aConfig The configuration to apply while parsing + * @return The parsed trace * @throws IOException * @throws ParserException */ public Trace parseTraceV0(File traceFile, Configuration aConfig) throws IOException, ParserException { Trace trace = new Trace(); trace.setTimeUnit(aConfig.getTimeScaleUnit()); - trace.setOffset(0l); - FileInputStream in = new FileInputStream(traceFile); - Parse(traceFile.getAbsolutePath(), in, aConfig, trace); - in.close(); + trace.setOffset(0L); + try (FileInputStream in = new FileInputStream(traceFile)) { + parse(traceFile.getAbsolutePath(), in, aConfig, trace); + } return trace; } @@ -102,21 +103,17 @@ public class ESIFormatTraceParser extends ESIFormatParser { return Math.pow(10.0, aConfig.getTimeScaleShift()); } - private void Parse(String src, FileInputStream in, Configuration aConfig, Trace aTrace) - throws IOException, ParserException { + private void parse(String src, FileInputStream in, Configuration aConfig, Trace aTrace) + throws IOException, ParserException + { final double PARSE_TIME_MULTIPLIER = getTimeMultiplier(aConfig); int n_TRACEVERSION = 0; int n_CONFIGURATIONID = 0; int n_TRACENAME = 0; int n_TRACESTARTTIME = 0; - int n_RESOURCE = 0; - int n_CLAIM = 0; - int n_DEPENDENCY = 0; - - BufferedReader reader = new BufferedReader(new InputStreamReader(in)); - try { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) { String line = null; int linenr = 0; @@ -125,18 +122,18 @@ public class ESIFormatTraceParser extends ESIFormatParser { String[] tok = line.split(SEPARATOR, -1); if (tok.length >= 2) { switch (tok[0]) { - case TRACEFORMATVERSION_TAG: - System.err.println( - TRACEFORMATVERSION_TAG + " is deprecated; use " + TRACEVERSION_TAG + " instead"); - case TRACEVERSION_TAG: - // aTrace.setTraceVersion(tok[1]); - if (!tok[1].equalsIgnoreCase(FORMAT_VERSION)) { - throw new ParserException("Trace version not supported " + tok[1], src, linenr); - } - n_TRACEVERSION++; - break; - default: - throw new ParserException("Trace version missing as first element", src, linenr); + case TRACEFORMATVERSION_TAG: + System.err.println( + TRACEFORMATVERSION_TAG + " is deprecated; use " + TRACEVERSION_TAG + " instead"); + case TRACEVERSION_TAG: + // aTrace.setTraceVersion(tok[1]); + if (!tok[1].equalsIgnoreCase(FORMAT_VERSION)) { + throw new ParserException("Trace version not supported " + tok[1], src, linenr); + } + n_TRACEVERSION++; + break; + default: + throw new ParserException("Trace version missing as first element", src, linenr); } } } @@ -150,276 +147,260 @@ public class ESIFormatTraceParser extends ESIFormatParser { Context context = null; switch (tok[0]) { - case CONFIGURATIONID_TAG: - if (n_CONFIGURATIONID > 0) { - throw new ParserException("ConfigurationID allready declared", src, linenr); - } - // aTrace.setConfigurationID(tok[1]); - if (!aConfig.getConfigurationID().equalsIgnoreCase(tok[1])) { - throw new ParserException( - "The Configuration required is notequal to actual Configuration", src, - linenr); - } - n_CONFIGURATIONID++; - break; - - case CONFIGURATION_SOURCE: - break; - case TRACENAME_TAG: - if (n_TRACENAME > 0) { - throw new ParserException("Trace name already declared", src, linenr); - } - aTrace.setAttribute(TRACENAME_TAG, tok[1]); - n_TRACENAME++; - break; - - case TRACEABSOLUTESTARTTIME_TAG: - System.err.println(TRACEABSOLUTESTARTTIME_TAG + " is deprecated; use " - + TRACESTARTTIME_TAG + " instead"); - case TRACESTARTTIME_TAG: - if (n_TRACESTARTTIME > 0) { - throw new ParserException("TraceStartTime already declared", src, linenr); - } + case CONFIGURATIONID_TAG: + if (n_CONFIGURATIONID > 0) { + throw new ParserException("ConfigurationID allready declared", src, linenr); + } + // aTrace.setConfigurationID(tok[1]); + if (!aConfig.getConfigurationID().equalsIgnoreCase(tok[1])) { + throw new ParserException( + "The Configuration required is notequal to actual Configuration", src, linenr); + } + n_CONFIGURATIONID++; + break; + + case CONFIGURATION_SOURCE: + break; + case TRACENAME_TAG: + if (n_TRACENAME > 0) { + throw new ParserException("Trace name already declared", src, linenr); + } + aTrace.setAttribute(TRACENAME_TAG, tok[1]); + n_TRACENAME++; + break; + + case TRACEABSOLUTESTARTTIME_TAG: + System.err.println(TRACEABSOLUTESTARTTIME_TAG + " is deprecated; use " + TRACESTARTTIME_TAG + + " instead"); + case TRACESTARTTIME_TAG: + if (n_TRACESTARTTIME > 0) { + throw new ParserException("TraceStartTime already declared", src, linenr); + } // aTrace.setTraceStartTime(tok[1]); - n_TRACESTARTTIME++; - break; - - case RESOURCE_TAG: - index = 1; - int rid; - try { - // Resource ID - rid = Integer.parseInt(tok[index]); - } catch (NumberFormatException e) { - throw new ParserException("ResourceID has illegal value " + tok[index], src, - linenr); - } - if (idResourceMap.containsKey(rid)) { - throw new ParserException("Resource(ID) already exists " + tok[index], src, - linenr); - } - - // Resource Capacity - if (tok.length <= ++index) { - throw new ParserException("Resource Capacity expected for resource id " + rid, - src, linenr); - } - double capacity; - try { - capacity = Double.parseDouble(tok[index]); - } catch (NumberFormatException e) { - throw new ParserException("Resource Capacity has illegal value " + tok[index], - src, linenr); - } - - // Resource Unit - if (tok.length <= ++index) { - throw new ParserException("Resource Unit expected for resource id " + rid, src, - linenr); - } - String unit = tok[index]; - - // Resource Claim Type - if (tok.length <= ++index) { - throw new ParserException("Claim type expected for resource id " + rid, src, - linenr); - } - Resource resource = null; - try { - int ict = Integer.parseInt(tok[index]); - ClaimType claimtype = ClaimType.get(ict); - if (claimtype == null) { - throw new ParserException("Claim type has unknown value " + tok[index], src, + n_TRACESTARTTIME++; + break; + + case RESOURCE_TAG: + index = 1; + int rid; + try { + // Resource ID + rid = Integer.parseInt(tok[index]); + } catch (NumberFormatException e) { + throw new ParserException("ResourceID has illegal value " + tok[index], src, linenr); + } + if (idResourceMap.containsKey(rid)) { + throw new ParserException("Resource(ID) already exists " + tok[index], src, linenr); + } + + // Resource Capacity + if (tok.length <= ++index) { + throw new ParserException("Resource Capacity expected for resource id " + rid, src, linenr); } - switch (claimtype) { - case FULL: - resource = new Resource(1, false); - resourceFullInstances.add(resource); - break; - case AMOUNT: - resource = new Resource(capacity, false); - break; - case AMOUNT_OFFSET: - resource = new Resource(capacity, true); - // Resource Offset - if (tok.length <= ++index) { - throw new ParserException( - "ResourceOffset expected for resource id " + rid, src, linenr); + double capacity; + try { + capacity = Double.parseDouble(tok[index]); + } catch (NumberFormatException e) { + throw new ParserException("Resource Capacity has illegal value " + tok[index], src, + linenr); + } + + // Resource Unit + if (tok.length <= ++index) { + throw new ParserException("Resource Unit expected for resource id " + rid, src, linenr); + } + String unit = tok[index]; + + // Resource Claim Type + if (tok.length <= ++index) { + throw new ParserException("Claim type expected for resource id " + rid, src, linenr); + } + Resource resource = null; + try { + int ict = Integer.parseInt(tok[index]); + ClaimType claimtype = ClaimType.get(ict); + if (claimtype == null) { + throw new ParserException("Claim type has unknown value " + tok[index], src, + linenr); } - try { - double offset = Double.parseDouble(tok[index]); - resourceOffsets.put(resource, offset); - } catch (NumberFormatException e) { - throw new ParserException( - "ResourceOffset has illegal value " + tok[index], src, linenr); + switch (claimtype) { + case FULL: + resource = new Resource(1, false); + resourceFullInstances.add(resource); + break; + case AMOUNT: + resource = new Resource(capacity, false); + break; + case AMOUNT_OFFSET: + resource = new Resource(capacity, true); + // Resource Offset + if (tok.length <= ++index) { + throw new ParserException("ResourceOffset expected for resource id " + rid, + src, linenr); + } + try { + double offset = Double.parseDouble(tok[index]); + resourceOffsets.put(resource, offset); + } catch (NumberFormatException e) { + throw new ParserException("ResourceOffset has illegal value " + tok[index], + src, linenr); + } + break; + default: + break; } - break; - default: - break; - } - } catch (NumberFormatException e) { - throw new ParserException("ClaimType has illegal value " + tok[index], src, - linenr); - } - resource.setAttribute("unit", unit); - - // Resource Context - if (tok.length <= ++index) { - throw new ParserException("Context expected for resource id " + rid, src, linenr); - } - try { - contextId = Integer.parseInt(tok[index]); - } catch (NumberFormatException e) { - throw new ParserException("Context has illegal value " + tok[index], src, linenr); - } - context = aConfig.getContext(contextId); - if (context == null) { - throw new ParserException( - "Resource context not defined in configuration: " + tok[index], src, - linenr); - } + } catch (NumberFormatException e) { + throw new ParserException("ClaimType has illegal value " + tok[index], src, linenr); + } + resource.setAttribute("unit", unit); + + // Resource Context + if (tok.length <= ++index) { + throw new ParserException("Context expected for resource id " + rid, src, linenr); + } + try { + contextId = Integer.parseInt(tok[index]); + } catch (NumberFormatException e) { + throw new ParserException("Context has illegal value " + tok[index], src, linenr); + } + context = aConfig.getContext(contextId); + if (context == null) { + throw new ParserException( + "Resource context not defined in configuration: " + tok[index], src, linenr); + } // resource.setContext(context); - if (tok.length <= index + context.getAttributes().size()) { - throw new ParserException( - "Invalid number of context arguments: " + context.getContextName(), src, - linenr); - } + if (tok.length <= index + context.getAttributes().size()) { + throw new ParserException( + "Invalid number of context arguments: " + context.getContextName(), src, + linenr); + } // resource.newAttValMap(context.getAttributes().size()); - for (Attribute att : context.getAttributes()) { - resource.setAttribute(att.getAttributeName(), tok[++index]); - } - addResource(resource, rid); - n_RESOURCE++; - break; - - case CLAIM_TAG: - index = 1; - // Claim id - int cid; - try { - cid = Integer.parseInt(tok[index]); - } catch (NumberFormatException e) { - throw new ParserException("ClaimID has illegal value " + tok[index], src, linenr); - } - if (idClaimMap.containsKey(cid)) { - throw new ParserException("Claim(ID) already exists " + tok[index], src, linenr); - } - - // Claim resource - if (tok.length <= ++index) { - throw new ParserException("Resource expected for claim id " + cid, src, linenr); - } - Claim claim = null; - try { - rid = Integer.parseInt(tok[index]); - } catch (NumberFormatException e) { - throw new ParserException("ResourceID has illegal value " + tok[index], src, - linenr); - } - resource = getResource(rid); - - if (resource == null) { - throw new ParserException("Resource not known " + tok[index], src, linenr); - } - - double amount = Double.NaN; - double offset = Double.NaN; - - if (resourceFullInstances.contains(resource)) { - amount = 1d; - } else if (!resourceOffsets.keySet().contains(resource)) { - // Claim amount + for (Attribute att: context.getAttributes()) { + resource.setAttribute(att.getAttributeName(), tok[++index]); + } + addResource(resource, rid); + break; + + case CLAIM_TAG: + index = 1; + // Claim id + int cid; + try { + cid = Integer.parseInt(tok[index]); + } catch (NumberFormatException e) { + throw new ParserException("ClaimID has illegal value " + tok[index], src, linenr); + } + if (idClaimMap.containsKey(cid)) { + throw new ParserException("Claim(ID) already exists " + tok[index], src, linenr); + } + + // Claim resource if (tok.length <= ++index) { - throw new ParserException("Amount expected for claim id " + cid, src, linenr); + throw new ParserException("Resource expected for claim id " + cid, src, linenr); } + Claim claim = null; try { - amount = Double.parseDouble(tok[index]); + rid = Integer.parseInt(tok[index]); } catch (NumberFormatException e) { - throw new ParserException("Amount has illegal value " + tok[index], src, - linenr); + throw new ParserException("ResourceID has illegal value " + tok[index], src, linenr); + } + resource = getResource(rid); + + if (resource == null) { + throw new ParserException("Resource not known " + tok[index], src, linenr); } - } else { - // Claim amount + + double amount = Double.NaN; + double offset = Double.NaN; + + if (resourceFullInstances.contains(resource)) { + amount = 1d; + } else if (!resourceOffsets.keySet().contains(resource)) { + // Claim amount + if (tok.length <= ++index) { + throw new ParserException("Amount expected for claim id " + cid, src, linenr); + } + try { + amount = Double.parseDouble(tok[index]); + } catch (NumberFormatException e) { + throw new ParserException("Amount has illegal value " + tok[index], src, linenr); + } + } else { + // Claim amount + if (tok.length <= ++index) { + throw new ParserException("Amount expected for claim id " + cid, src, linenr); + } + try { + amount = Double.parseDouble(tok[index]); + } catch (NumberFormatException e) { + throw new ParserException("Aount has illegal value " + tok[index], src, linenr); + } + // Claim offset + if (tok.length <= ++index) { + throw new ParserException("Offset expected for claim id " + cid, src, linenr); + } + try { + offset = Double.parseDouble(tok[index]) + resourceOffsets.get(resource); + } catch (NumberFormatException e) { + throw new ParserException("Offset has illegal value " + tok[index], src, linenr); + } + } + + // Claim start time + double starttime; if (tok.length <= ++index) { - throw new ParserException("Amount expected for claim id " + cid, src, linenr); + throw new ParserException("Start time expected for claim id " + cid, src, linenr); } try { - amount = Double.parseDouble(tok[index]); + starttime = PARSE_TIME_MULTIPLIER * Double.parseDouble(tok[index]); } catch (NumberFormatException e) { - throw new ParserException("Aount has illegal value " + tok[index], src, - linenr); + throw new ParserException("Start time has illegal value " + tok[index], src, linenr); } - // Claim offset + + // Claim stop time + double stoptime; if (tok.length <= ++index) { - throw new ParserException("Offset expected for claim id " + cid, src, linenr); + throw new ParserException("Stop time expected for claim id " + cid, src, linenr); } try { - offset = Double.parseDouble(tok[index]) + resourceOffsets.get(resource); + stoptime = PARSE_TIME_MULTIPLIER * Double.parseDouble(tok[index]); + // Alternative to avoid noise in LSBs at High values + // MathContext mathcontext = new MathContext(15, RoundingMode.HALF_UP); + // BigDecimal multiplicand = new BigDecimal( 1.0E12, mathcontext ); + // BigDecimal bb = new BigDecimal( Double.parseDouble(tok[index]), mathcontext); + // stoptime = (bb.multiply(multiplicand)).longValue(); } catch (NumberFormatException e) { - throw new ParserException("Offset has illegal value " + tok[index], src, - linenr); + throw new ParserException("Stop time has illegal value " + tok[index], src, linenr); } - } - - // Claim start time - double starttime; - if (tok.length <= ++index) { - throw new ParserException("Start time expected for claim id " + cid, src, linenr); - } - try { - starttime = PARSE_TIME_MULTIPLIER * Double.parseDouble(tok[index]); - } catch (NumberFormatException e) { - throw new ParserException("Start time has illegal value " + tok[index], src, - linenr); - } - - // Claim stop time - double stoptime; - if (tok.length <= ++index) { - throw new ParserException("Stop time expected for claim id " + cid, src, linenr); - } - try { - stoptime = PARSE_TIME_MULTIPLIER * Double.parseDouble(tok[index]); - // Alternative to avoid noise in LSBs at High values - // MathContext mathcontext = new MathContext(15, RoundingMode.HALF_UP); - // BigDecimal multiplicand = new BigDecimal( 1.0E12, mathcontext ); - // BigDecimal bb = new BigDecimal( Double.parseDouble(tok[index]), mathcontext); - // stoptime = (bb.multiply(multiplicand)).longValue(); - } catch (NumberFormatException e) { - throw new ParserException("Stop time has illegal value " + tok[index], src, - linenr); - } - if (starttime > stoptime) { - throw new ParserException("Stop time is before start time for claim id " + cid, - src, linenr); - } - if (Double.isNaN(offset)) { - claim = new Claim(starttime, stoptime, resource, amount); - } else { - claim = new Claim(starttime, stoptime, resource, offset, amount); - } - - // Limitations Type - if (tok.length <= ++index) { - throw new ParserException("Limitations type expected for claim id " + cid, src, - linenr); - } - try { - int ilt = Integer.parseInt(tok[index]); - LimitationsType lt = LimitationsType.get(ilt); - if (lt == null) { - throw new ParserException( - "Period limitations type has unknown value " + tok[index], src, + if (starttime > stoptime) { + throw new ParserException("Stop time is before start time for claim id " + cid, src, linenr); } - if (ilt != LimitationsType.NONE_VALUE) { + if (Double.isNaN(offset)) { + claim = new Claim(starttime, stoptime, resource, amount); + } else { + claim = new Claim(starttime, stoptime, resource, offset, amount); + } + + // Limitations Type + if (tok.length <= ++index) { + throw new ParserException("Limitations type expected for claim id " + cid, src, linenr); + } + try { + int ilt = Integer.parseInt(tok[index]); + LimitationsType lt = LimitationsType.get(ilt); + if (lt == null) { + throw new ParserException("Period limitations type has unknown value " + tok[index], + src, linenr); + } + if (ilt != LimitationsType.NONE_VALUE) { // Limitations lim = factory.createLimitations(); - if ((ilt & LimitationsType.MIN_START_VALUE) != 0) { - if (tok.length <= ++index) { - throw new ParserException("MinStarttime expected for claim id " + cid, - src, linenr); - } + if ((ilt & LimitationsType.MIN_START_VALUE) != 0) { + if (tok.length <= ++index) { + throw new ParserException("MinStarttime expected for claim id " + cid, src, + linenr); + } // try { // lim.setMinStartTime(Math // .round(PARSE_TIME_MULTIPLIER * Double.parseDouble(tok[index]))); @@ -429,12 +410,12 @@ public class ESIFormatTraceParser extends ESIFormatParser { // + tok[index], // src, linenr); // } - } - if ((ilt & LimitationsType.MAX_STOP_VALUE) != 0) { - if (tok.length <= ++index) { - throw new ParserException("MaxStoptime expected for Claim id " + cid, - src, linenr); } + if ((ilt & LimitationsType.MAX_STOP_VALUE) != 0) { + if (tok.length <= ++index) { + throw new ParserException("MaxStoptime expected for Claim id " + cid, src, + linenr); + } // try { // lim.setMaxStopTime(Math // .round(PARSE_TIME_MULTIPLIER * Double.parseDouble(tok[index]))); @@ -451,160 +432,154 @@ public class ESIFormatTraceParser extends ESIFormatParser { // src, linenr); // } // } - } - if ((ilt & LimitationsType.MAX_DURATION_VALUE) != 0) { - if (tok.length <= ++index) { - throw new ParserException("MaxDuration expected for claim id " + cid, - src, linenr); } - try { - long max_duration = Math - .round(PARSE_TIME_MULTIPLIER * Double.parseDouble(tok[index])); - if (max_duration < 0) { - throw new ParserException( - "Negative value for claim limitation MaxDuration is not allowed for claim id " - + cid, - src, linenr); + if ((ilt & LimitationsType.MAX_DURATION_VALUE) != 0) { + if (tok.length <= ++index) { + throw new ParserException("MaxDuration expected for claim id " + cid, src, + linenr); } + try { + long max_duration = Math + .round(PARSE_TIME_MULTIPLIER * Double.parseDouble(tok[index])); + if (max_duration < 0) { + throw new ParserException( + "Negative value for claim limitation MaxDuration is not allowed for claim id " + + cid, + src, linenr); + } // lim.setMaxDuration(max_duration); - } catch (NumberFormatException e) { - throw new ParserException( -