From 26677ec64e637ed4af106d38f1629d8dd601736e Mon Sep 17 00:00:00 2001 From: Yuri Blankenstein Date: Tue, 15 Mar 2022 14:44:33 +0100 Subject: [PATCH 1/4] #13 Enable checkstyle for jfreechart --- .gitignore | 3 - TRACE4CPS.setup | 294 +++- .../.checkstyle | 7 + .../.project | 6 + .../jfreechart/ui/JFreeChartUIPlugin.java | 31 +- .../jfreechart/ui/gantt/XYGanttDataItem.java | 51 +- .../ui/gantt/XYGanttDependencyItem.java | 79 +- .../ui/gantt/XYGanttMeasurement.java | 97 +- .../gantt/XYGanttMeasurementAnnotation.java | 206 +-- ...YGanttMeasurementAnnotationDescriptor.java | 185 +-- .../ui/internal/ChartPanelFactory.java | 3 +- .../internal/ChartPanelScrollbarHandler.java | 85 +- .../internal/DefaultChartThemeSupplier.java | 1 + .../ui/theme/ChartThemeSupplier.java | 1 + .../ui/theme/DefaultChartTheme.java | 95 +- .../ui/viewers/BackReferenceProvider.java | 1 + .../ui/viewers/BackReferenceResolver.java | 69 +- .../viewers/BackReferenceTextGenerator.java | 8 +- .../ui/viewers/ChartPanelContentViewer.java | 59 +- .../viewers/ChartPanelSelectionHandler.java | 224 ++- .../ui/viewers/SelectionProvider.java | 31 +- .../ui/widgets/ChartPanelComposite.java | 107 +- .../.checkstyle | 7 + .../.project | 6 + .../chart/ZoomAndPanKeyboardHandler.java | 227 ++- .../chart/ZoomMouseWheelHandler.java | 3 +- .../jfreechart/chart/axis/AxisUtils.java | 237 ++- .../common/jfreechart/chart/axis/Section.java | 448 ++--- .../jfreechart/chart/axis/SectionAxis.java | 1436 ++++++++--------- .../jfreechart/chart/axis/SectionTick.java | 80 +- .../common/jfreechart/chart/geom/Arrow2D.java | 126 +- .../jfreechart/chart/geom/Triangle2D.java | 111 +- .../jfreechart/chart/plot/PlotUtils.java | 41 +- .../chart/renderer/xy/XYEdgeRenderer.java | 573 +++---- .../chart/renderer/xy/XYImageRenderer.java | 101 +- .../jfreechart/data/xy/XYEdgeDataItem.java | 114 +- .../jfreechart/data/xy/XYEdgeSeries.java | 127 +- .../data/xy/XYEdgeSeriesCollection.java | 197 ++- .../jfreechart/data/xy/XYScaledSeries.java | 341 ++-- .../data/xy/XYScaledSeriesCollection.java | 35 +- .../checkstyle.xml | 276 ++++ .../pom.xml | 45 + .../org.eclipse.trace4cps.target.target | 8 +- 43 files changed, 3333 insertions(+), 2849 deletions(-) create mode 100644 jfreechart/org.eclipse.trace4cps.common.jfreechart.ui/.checkstyle create mode 100644 jfreechart/org.eclipse.trace4cps.common.jfreechart/.checkstyle create mode 100644 releng/org.eclipse.trace4cps.configuration/checkstyle.xml diff --git a/.gitignore b/.gitignore index 2f9595f..be49e74 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 ae331e4..aecf26d 100644 --- a/TRACE4CPS.setup +++ b/TRACE4CPS.setup @@ -114,11 +114,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 7a38e78..eda9443 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 c73d60c..ad920dd 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 89bff77..d6b5d05 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 06b3740..abbefad 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 584df0d..2455086 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 31a994b..567cec2 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 ffe186b..9f071a6 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 8146b1c..7717a93 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 6d6746d..baebeaf 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 b774529..a4ca789 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 185cd87..3e40436 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 b1cf6cd..14d9c8f 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 81608da..241dea5 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 7da50fe..ef6ff57 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 87bc98c..56b21f9 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 bccee96..8843338 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 6e6f609..0a02096 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 5ed7933..139f713 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 8c9f6dc..4159136 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 0000000..b01fc54 --- /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 ba32884..d945523 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 47e8b39..ecf4964 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 195f14d..aeaaf2e 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 483c1c9..e820dc7 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 ce91519..53eeac5 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 0a6ee5f..07aef42 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 d51dcef..476598b 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 bdeabde..24eba9c 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 3922509..829993b 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 0056fc9..929afb8 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 8ee05c6..2c1402c 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 96b72da..aa0ebec 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 80a38fb..bf9977c 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 7884b6a..467c86a 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 cfc9823..8c9e9aa 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 ae5fdac..2cbfcb8 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 7909420..f82b642 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 0000000..b706390 --- /dev/null +++ b/releng/org.eclipse.trace4cps.configuration/checkstyle.xml @@ -0,0 +1,276 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/releng/org.eclipse.trace4cps.configuration/pom.xml b/releng/org.eclipse.trace4cps.configuration/pom.xml index 81bd51b..e218c41 100644 --- a/releng/org.eclipse.trace4cps.configuration/pom.xml +++ b/releng/org.eclipse.trace4cps.configuration/pom.xml @@ -40,6 +40,10 @@ 0.0.1-SNAPSHOT + + + 3.1.2 + 8.41 @@ -282,6 +286,47 @@ + + + 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 + + + check + + + + + + + + add-plugin-default-abouts 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 ef5e18a..1210d16 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 @@ - - - -- GitLab From 3daef78faa88d4990d5ada2b0e60a4f830f7ee49 Mon Sep 17 00:00:00 2001 From: Yuri Blankenstein Date: Wed, 16 Mar 2022 08:02:59 +0100 Subject: [PATCH 2/4] #13 Enable checkstyle for trace --- TRACE4CPS.setup | 8 + .../checkstyle.xml | 9 +- .../.checkstyle | 7 + .../org.eclipse.trace4cps.core.tests/.project | 6 + .../behavior/test/BehavioralAnalysisTest.java | 15 +- .../FilteringClaimRepresentationTest.java | 39 +- .../test/ConstraintGraphTest.java | 24 +- .../trace4cps/analysis/cpa/test/CPATest.java | 13 +- .../dist/test/DependencyAnalysisTest.java | 2 +- .../dist/test/DistanceAnalysisTest.java | 5 +- .../test/CompactExplanationTableImplTest.java | 19 +- .../analysis/mtl/check/test/DefaultState.java | 8 +- .../analysis/mtl/test/MtlCheckerTest.java | 25 +- .../signal/test/EventSignalUtilTest.java | 5 +- .../analysis/signal/test/SignalUtilTest.java | 12 +- .../analysis/stl/test/PsopBuilder.java | 2 +- .../analysis/stl/test/PsopFragmentTest.java | 15 +- .../trace4cps/analysis/stl/test/PsopTest.java | 15 +- .../analysis/stl/test/StlBuilderTest.java | 8 +- .../analysis/stl/test/StlUtilTest.java | 6 +- .../timing/test/StatisticsManagerTest.java | 3 +- .../core/impl/test/AttributeAwareTest.java | 4 +- .../core/impl/test/ClaimEventTest.java | 5 +- .../trace4cps/core/impl/test/ClaimTest.java | 30 +- .../trace4cps/core/impl/test/EventTest.java | 2 +- .../core/impl/test/IntervalTest.java | 6 +- .../core/impl/test/ModifiableTraceTest.java | 3 +- .../core/impl/test/PsopFragmentTest.java | 29 +- .../trace4cps/core/impl/test/PsopTest.java | 13 +- .../core/impl/test/ResourceTest.java | 6 +- .../trace4cps/core/impl/test/TraceTest.java | 8 +- .../trace4cps/core/io/test/TraceIOTest.java | 27 +- trace/org.eclipse.trace4cps.core/.checkstyle | 7 + trace/org.eclipse.trace4cps.core/.project | 6 + .../trace4cps/analysis/AnalysisException.java | 2 +- .../trace4cps/analysis/behavior/Behavior.java | 6 +- .../analysis/behavior/BehavioralAnalysis.java | 36 +- .../behavior/BehavioralPartition.java | 21 +- .../analysis/behavior/HistogramEntry.java | 16 +- .../impl/FilteringClaimRepresentation.java | 30 +- .../constraintgraph/ConstraintConfig.java | 34 +- .../constraintgraph/impl/ClaimNode.java | 10 +- .../constraintgraph/impl/Constraint.java | 15 +- .../constraintgraph/impl/ConstraintGraph.java | 122 ++- .../impl/ConstraintGraphNode.java | 13 +- .../constraintgraph/impl/EventNode.java | 2 +- .../constraintgraph/impl/SrcSnkNode.java | 5 +- .../trace4cps/analysis/cpa/CpaResult.java | 8 +- .../analysis/cpa/CriticalPathAnalysis.java | 54 +- .../analysis/cpa/DependencyProvider.java | 8 +- .../analysis/cpa/PositiveCycleException.java | 2 +- .../analysis/dist/DefaultRepresentation.java | 10 +- .../dist/DependencyInclusionCheck.java | 44 +- .../analysis/dist/DistanceAnalysis.java | 78 +- .../analysis/dist/DistanceResult.java | 10 +- .../analysis/dist/Representation.java | 4 +- .../analysis/mtl/AtomicProposition.java | 22 +- .../mtl/DefaultAtomicProposition.java | 2 +- .../analysis/mtl/ExplanationTable.java | 7 +- .../analysis/mtl/InformativePrefix.java | 15 +- .../trace4cps/analysis/mtl/MtlBuilder.java | 8 +- .../trace4cps/analysis/mtl/MtlChecker.java | 77 +- .../trace4cps/analysis/mtl/MtlException.java | 2 +- .../trace4cps/analysis/mtl/MtlFormula.java | 2 +- .../trace4cps/analysis/mtl/MtlFuture.java | 5 +- .../trace4cps/analysis/mtl/MtlResult.java | 7 +- .../trace4cps/analysis/mtl/MtlUtil.java | 25 +- .../eclipse/trace4cps/analysis/mtl/State.java | 14 +- .../check/CompactExplanationTableImpl.java | 36 +- .../check/RecursiveMemoizationChecker.java | 25 +- .../analysis/mtl/check/RegionImpl.java | 9 +- .../mtl/check/SingleFormulaChecker.java | 2 +- .../mtl/check/TabularExplanationTable.java | 2 +- .../mtl/impl/AbstractBinopMTLformula.java | 2 +- .../analysis/mtl/impl/AbstractMTLformula.java | 4 +- .../analysis/mtl/impl/DoubleIExp.java | 4 +- .../trace4cps/analysis/mtl/impl/IExp.java | 5 +- .../trace4cps/analysis/mtl/impl/IntIExp.java | 2 +- .../trace4cps/analysis/mtl/impl/MTLand.java | 2 +- .../trace4cps/analysis/mtl/impl/MTLimply.java | 2 +- .../trace4cps/analysis/mtl/impl/MTLnot.java | 6 +- .../trace4cps/analysis/mtl/impl/MTLor.java | 2 +- .../trace4cps/analysis/mtl/impl/MTLtrue.java | 2 +- .../trace4cps/analysis/mtl/impl/MTLuntil.java | 2 +- .../trace4cps/analysis/mtl/impl/OpIExp.java | 50 +- .../trace4cps/analysis/mtl/impl/VarIExp.java | 6 +- .../analysis/resource/ResourceAnalysis.java | 22 +- .../impl/ResourceClientHistogram.java | 15 +- .../analysis/signal/SignalModifier.java | 8 +- .../trace4cps/analysis/signal/SignalUtil.java | 103 ++- .../analysis/signal/impl/EventSignalUtil.java | 81 +- .../signal/impl/LinearSignalFragment.java | 5 +- .../analysis/signal/impl/PsopHelper.java | 172 ++-- .../trace4cps/analysis/stl/StlBuilder.java | 6 +- .../trace4cps/analysis/stl/StlException.java | 2 +- .../trace4cps/analysis/stl/StlFormula.java | 9 +- .../analysis/stl/impl/AbstractStlFormula.java | 2 +- .../trace4cps/analysis/stl/impl/STLUtil.java | 41 +- .../analysis/stl/impl/StlBinBool.java | 21 +- .../trace4cps/analysis/stl/impl/StlEq.java | 2 +- .../trace4cps/analysis/stl/impl/StlGeq.java | 2 +- .../trace4cps/analysis/stl/impl/StlLeq.java | 2 +- .../trace4cps/analysis/stl/impl/StlNeg.java | 2 +- .../trace4cps/analysis/stl/impl/StlTrue.java | 2 +- .../trace4cps/analysis/stl/impl/StlUntil.java | 2 +- .../analysis/timing/NormalStatistics.java | 3 +- .../analysis/timing/StatisticsManager.java | 97 ++- .../analysis/timing/TimingAnalysis.java | 13 +- .../trace4cps/core/ClaimEventType.java | 1 + .../trace4cps/core/IAttributeAware.java | 6 +- .../trace4cps/core/IAttributeFilter.java | 6 +- .../org/eclipse/trace4cps/core/IClaim.java | 11 +- .../eclipse/trace4cps/core/IClaimEvent.java | 10 +- .../eclipse/trace4cps/core/IDependency.java | 2 +- .../org/eclipse/trace4cps/core/IEvent.java | 8 +- .../trace4cps/core/IExtendableTrace.java | 2 +- .../trace4cps/core/IFilteredTrace.java | 31 +- .../org/eclipse/trace4cps/core/IInterval.java | 2 +- .../src/org/eclipse/trace4cps/core/IPsop.java | 10 +- .../eclipse/trace4cps/core/IPsopFragment.java | 6 +- .../org/eclipse/trace4cps/core/IResource.java | 8 +- .../org/eclipse/trace4cps/core/ITrace.java | 26 +- .../src/org/eclipse/trace4cps/core/Shape.java | 1 + .../trace4cps/core/TraceException.java | 2 +- .../org/eclipse/trace4cps/core/TracePart.java | 1 + .../trace4cps/core/impl/AttributeAware.java | 11 +- .../eclipse/trace4cps/core/impl/Claim.java | 19 +- .../trace4cps/core/impl/ClaimEvent.java | 4 +- .../trace4cps/core/impl/Dependency.java | 2 +- .../eclipse/trace4cps/core/impl/Event.java | 2 +- .../eclipse/trace4cps/core/impl/Interval.java | 38 +- .../trace4cps/core/impl/ModifiableTrace.java | 192 ++-- .../org/eclipse/trace4cps/core/impl/Psop.java | 14 +- .../trace4cps/core/impl/PsopFragment.java | 5 +- .../eclipse/trace4cps/core/impl/Resource.java | 5 +- .../eclipse/trace4cps/core/impl/Trace.java | 17 +- .../trace4cps/core/impl/TraceHelper.java | 30 +- .../trace4cps/core/io/DependencyType.java | 4 +- .../trace4cps/core/io/ParseException.java | 2 +- .../trace4cps/core/io/TraceReader.java | 112 ++- .../trace4cps/core/io/TraceWriter.java | 54 +- .../trace4cps/core/io/conv/Attribute.java | 366 ++++---- .../core/io/conv/AttributeUsageType.java | 443 +++++----- .../core/io/conv/AttributeValueType.java | 308 +++---- .../trace4cps/core/io/conv/ClaimType.java | 352 ++++---- .../trace4cps/core/io/conv/Configuration.java | 127 ++- .../trace4cps/core/io/conv/Context.java | 187 ++-- .../core/io/conv/DependencyType.java | 396 ++++----- .../io/conv/ESIFormatConfigurationParser.java | 445 +++++----- .../core/io/conv/ESIFormatParser.java | 13 +- .../core/io/conv/ESIFormatTraceParser.java | 822 +++++++++--------- .../core/io/conv/LimitationsType.java | 509 +++++------ .../core/io/conv/ParserException.java | 5 +- .../core/io/conv/TraceConverter.java | 12 +- .../.checkstyle | 7 + trace/org.eclipse.trace4cps.ui.tests/.project | 6 + .../trace4cps/ui/test/LogisticsCPAtest.java | 19 +- .../trace4cps/ui/test/PlotUtilTest.java | 14 +- .../trace4cps/ui/test/STTTpaperTest.java | 65 +- trace/org.eclipse.trace4cps.ui/.checkstyle | 7 + trace/org.eclipse.trace4cps.ui/.project | 6 + .../eclipse/trace4cps/ui/AnalysisUtil.java | 188 ++-- .../org/eclipse/trace4cps/ui/ConsoleUtil.java | 9 +- .../trace4cps/ui/FileSelectionUtil.java | 15 +- .../trace4cps/ui/TracePerspectiveFactory.java | 11 +- .../trace4cps/ui/action/OpenTraceView.java | 20 +- .../AbstractListSelectionWizardPage.java | 15 +- .../trace4cps/ui/dialog/BehaviorWizard.java | 7 +- .../trace4cps/ui/dialog/CPAdialog.java | 11 +- .../ui/dialog/DependencyAnalysisWizard.java | 6 +- .../trace4cps/ui/dialog/DistanceDialog.java | 5 +- .../trace4cps/ui/dialog/FilterWizard.java | 30 +- .../trace4cps/ui/dialog/LittlesLawDialog.java | 30 +- .../trace4cps/ui/dialog/ParameterDialog.java | 32 +- .../dialog/ResourceClientHistogramDialog.java | 12 +- .../eclipse/trace4cps/ui/view/ChartView.java | 11 +- .../trace4cps/ui/view/ClaimDataItem.java | 22 +- .../trace4cps/ui/view/DependencyDataItem.java | 6 +- .../ui/view/EclipseDataItemFactory.java | 11 +- .../ui/view/EclipseSelectionWrapper.java | 19 +- .../ui/view/EclipseToolTipGenerator.java | 24 +- .../trace4cps/ui/view/EventDataItem.java | 6 +- .../trace4cps/ui/view/SignalDataItem.java | 6 +- .../eclipse/trace4cps/ui/view/TraceView.java | 133 ++- .../trace4cps/ui/view/TraceViewer.java | 123 +-- .../view/action/AbstractPartitionAction.java | 4 +- .../view/action/AbstractTraceViewAction.java | 2 +- .../ui/view/action/BehaviorClassesAction.java | 6 +- .../view/action/BehaviorHistogramAction.java | 2 +- .../action/BehaviorRepresentativesAction.java | 5 +- .../action/ClaimDescriptionToggleAction.java | 2 +- .../ui/view/action/ClearExtensionAction.java | 2 +- .../ui/view/action/ClearFilterAction.java | 2 +- .../ui/view/action/ColoringAction.java | 18 +- .../ui/view/action/CriticalPathAction.java | 6 +- .../ui/view/action/DependencyAction.java | 6 +- .../ui/view/action/DescribingAction.java | 26 +- .../ui/view/action/DistanceAction.java | 4 +- .../view/action/DropDownAggregateAction.java | 13 +- .../ui/view/action/FilterAction.java | 26 +- .../ui/view/action/GroupingAction.java | 14 +- .../trace4cps/ui/view/action/HideAction.java | 70 +- .../ui/view/action/LatencyAction.java | 9 +- .../view/action/ResourceHistogramAction.java | 10 +- .../ui/view/action/ResourceUsageAction.java | 10 +- .../action/SaveViewConfigurationAction.java | 2 +- .../ui/view/action/SeparatorAction.java | 1 + .../ui/view/action/ThroughputEventAction.java | 16 +- .../ui/view/action/ThroughputIdAction.java | 9 +- .../ui/view/action/TimingAnalysisAction.java | 6 +- .../view/action/ToggleClaimScaleAction.java | 30 +- .../ui/view/action/ToggleSignalAction.java | 2 +- .../ui/view/action/ToggleViewAction.java | 2 +- .../ui/view/action/VerifyAction.java | 37 +- .../trace4cps/ui/view/action/WipAction.java | 6 +- .../trace4cps/ui/view/timing/LabeledNode.java | 2 +- .../trace4cps/ui/view/timing/RootNode.java | 5 +- .../trace4cps/ui/view/timing/SectionNode.java | 2 +- .../ui/view/timing/TimingAnalysisView.java | 60 +- .../trace4cps/ui/view/verify/CheckNode.java | 3 +- .../trace4cps/ui/view/verify/FileNode.java | 6 +- .../view/verify/ParameterizedCheckNode.java | 3 +- .../trace4cps/ui/view/verify/ResultNode.java | 9 +- .../trace4cps/ui/view/verify/ResultTree.java | 16 +- .../trace4cps/ui/view/verify/SpecNode.java | 8 +- .../view/verify/VerificationResultView.java | 106 ++- .../.checkstyle | 7 + .../org.eclipse.trace4cps.vis.tests/.project | 6 + .../vis/jfree/test/PartitionTest.java | 4 +- .../test/TraceViewConfigurationIOTest.java | 12 +- trace/org.eclipse.trace4cps.vis/.checkstyle | 7 + trace/org.eclipse.trace4cps.vis/.project | 6 + .../trace4cps/vis/jfree/ClaimDataItem.java | 58 +- .../trace4cps/vis/jfree/ClaimScaling.java | 18 +- .../trace4cps/vis/jfree/ColorManager.java | 180 ++-- .../trace4cps/vis/jfree/DataItemFactory.java | 2 +- .../vis/jfree/DefaultDataItemFactory.java | 13 +- .../vis/jfree/DefaultToolTipGenerator.java | 16 +- .../vis/jfree/DependencyDataItem.java | 12 +- .../trace4cps/vis/jfree/EventDataItem.java | 14 +- .../trace4cps/vis/jfree/SignalDataItem.java | 6 +- .../trace4cps/vis/jfree/TracePlotManager.java | 144 ++- .../vis/jfree/TraceViewConfiguration.java | 141 ++- .../vis/jfree/TraceViewConfigurationIO.java | 193 ++-- .../trace4cps/vis/jfree/impl/Cell.java | 2 +- .../trace4cps/vis/jfree/impl/ClaimCell.java | 64 +- .../vis/jfree/impl/ClaimFragment.java | 2 +- .../vis/jfree/impl/ClaimPartition.java | 10 +- .../trace4cps/vis/jfree/impl/Partition.java | 9 +- 249 files changed, 4220 insertions(+), 4662 deletions(-) create mode 100644 trace/org.eclipse.trace4cps.core.tests/.checkstyle create mode 100644 trace/org.eclipse.trace4cps.core/.checkstyle create mode 100644 trace/org.eclipse.trace4cps.ui.tests/.checkstyle create mode 100644 trace/org.eclipse.trace4cps.ui/.checkstyle create mode 100644 trace/org.eclipse.trace4cps.vis.tests/.checkstyle create mode 100644 trace/org.eclipse.trace4cps.vis/.checkstyle diff --git a/TRACE4CPS.setup b/TRACE4CPS.setup index aecf26d..b64d88c 100644 --- a/TRACE4CPS.setup +++ b/TRACE4CPS.setup @@ -80,6 +80,14 @@ + + + diff --git a/releng/org.eclipse.trace4cps.configuration/checkstyle.xml b/releng/org.eclipse.trace4cps.configuration/checkstyle.xml index b706390..12c455f 100644 --- a/releng/org.eclipse.trace4cps.configuration/checkstyle.xml +++ b/releng/org.eclipse.trace4cps.configuration/checkstyle.xml @@ -26,7 +26,10 @@ Eclipse TRACE4CPS Checkstyle Copyright (c) 2021 Contributors to the Eclipse Fou - + + + + @@ -37,7 +40,7 @@ Eclipse TRACE4CPS Checkstyle Copyright (c) 2021 Contributors to the Eclipse Fou - + @@ -45,9 +48,11 @@ Eclipse TRACE4CPS Checkstyle Copyright (c) 2021 Contributors to the Eclipse Fou + + diff --git a/trace/org.eclipse.trace4cps.core.tests/.checkstyle b/trace/org.eclipse.trace4cps.core.tests/.checkstyle new file mode 100644 index 0000000..b01fc54 --- /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 944a764..db44099 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 dc62d23..bd28821 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 562ce82..cb1233e 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 d81fb24..0f340d1 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 ac988f5..6bce285 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 3d6033d..3fd7b11 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 9607892..7d72e2f 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 c0e5cff..85385a8 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 8ac2431..dc9e21d 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 8ac91cb..71d985b 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 48edc0c..b5940b4 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 454467f..8ee9f65 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 1409673..33887af 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 f0ef780..d718aa4 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 17b44d3..aee11d3 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 572d374..4659190 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 1b22b8e..2075821 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 aa46e4b..7c3c8df 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 d94cbe2..ae868ec 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 4d77a5e..725ebee 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 5b155e2..3eac987 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 ac23f96..cf91d77 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 a83776e..152ceb3 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 df5f78e..d1103fe 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 6050594..9eae852 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 70f3eb4..af0b153 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 edb15c9..f84575f 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 f7635e6..6c9e3b4 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 c8f5034..127aa49 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 0000000..b01fc54 --- /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 38b0226..26ec916 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 6ecc40f..c570287 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 fcb1d3c..94d9447 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 ee95187..edc86f1 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 e2c64fb..908d2da 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 759ac8b..c1ea764 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 d524713..ef8d2cd 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 94f0473..197f4b3 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 8279221..2c82462 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 80726f3..883b4fa 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 552dfc3..4d5bea6 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 1248a55..66ced3a 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 df51665..41a86d5 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 7455b55..5ba2f6a 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 24ff157..73223aa 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 da6e9ee..bf4b4d1 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 52ad0c5..b683964 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 1589385..4fd3a7f 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 376a92c..8919d78 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 ffaaeb6..e06e570 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 9be7f27..0f9ec3e 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 f38a684..bdf78a7 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 fea63f1..a99d6f0 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 fc565cc..1d50a49 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 0ccd220..57b8c0c 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 948849b..c2a9501 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 fc28b5b..c3d2332 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 40cdd9b..e07e954 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 e6d0154..ba19c6d 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 a3ad67e..f2b4ed0 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 11465ee..3af3196 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 c996239..b81f5af 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 8e565a0..aa48f57 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 80e4c5f..f1be370 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 d783a5e..73ac1f0 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 b625169..d6fa447 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 6c29705..2b651ad 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 cf3522a..1d60e22 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 1aa7155..d847f9c 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 2938e21..b9064fa 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 a3b5e27..3c955da 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 aa6d97e..822b5d0 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 8334516..6917749 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 2215656..f5016f7 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 658f279..e46ab31 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 a452cc0..55be60d 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 b3b8858..642eb4c 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 a2e43fd..e330015 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 31c1819..0b438e6 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 b353e37..a051c50 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 e65d589..3e1c787 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 569d251..4e06e68 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 a757a37..18aadb9 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 e3fcfc7..422742e 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 1b165b1..183d928 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 3944cda..e4a59ed 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 c19e70d..812aee4 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 e72da70..d778745 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 69d2a6b..5ed5038 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 7b8a6e3..4196220 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 796a76d..d6944f0 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 6169e0f..d110fc9 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 78f6aaf..3f079ef 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 a885a11..d2a807e 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 b4773b8..e4688cd 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 978b7b0..5be0db8 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 0e53654..6faafcf 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 9bb6c73..9ecb65d 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 5f8c323..e3d9056 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 dd7184d..fe0fa17 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 4dd32ee..d76ca44 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 0e48f92..4769c48 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 3e7c338..ab9fd0e 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 33b9dba..8c398ef 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 5a94983..2edb886 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 2c4d9a3..9486916 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 2641e34..3f8d901 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 31b025f..e2fec8a 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 249481e..6eee4aa 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 deccd25..6660fa9 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 28be3a6..aedb54c 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 747a6c7..0ee4ade 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 b2da70a..2753c8f 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 e49a580..0206484 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 866bb94..b25dda1 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 30328f1..b929d7d 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 060a42c..3d47a0f 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 f846e76..ca0c119 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 260da0f..99e5c35 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 a086141..d4a21a5 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 e81a010..a901acc 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 268a0c1..1ac45dd 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 d985970..580319d 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 c21f3cc..59c2710 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 d962033..3047a73 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 027ba4d..11d76e1 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 c92a0a8..8b2210b 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 b81bdda..646cd66 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 558f6c4..eefe1d7 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 1c6eb2f..3cc9f29 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 2137b7d..0f81588 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 007f5ea..af22f3a 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 40de5c4..c38954b 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 c00d253..9ce6607 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 09a47e7..7f6483e 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 eb99b23..6bb0522 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 7271f15..21f62a9 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 3b79267..a8a7815 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 23f2af3..9b977b1 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 77b64ff..8299627 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 f275853..463aca5 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 0f15bec..b4bdde2 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 811c6af..7f59d06 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 8e5567b..cd26ede 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 6a5fb6b..59057d1 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( - "Claim limitation MaxDuration has illegal value " - + tok[index], - src, linenr); + } catch (NumberFormatException e) { + throw new ParserException( + "Claim limitation MaxDuration has illegal value " + tok[index], src, + linenr); + } } - } // claim.setLimitations(lim); + } + } catch (NumberFormatException e) { + throw new ParserException("Limitations type has illegal value " + tok[index], src, + linenr); + } + + // Claim context + if (tok.length <= ++index) { + throw new ParserException("Context expected for claim id " + cid, 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("Claim context not defined in configuration: " + tok[index], + src, linenr); } - } catch (NumberFormatException e) { - throw new ParserException("Limitations type has illegal value " + tok[index], src, - linenr); - } - - // Claim context - if (tok.length <= ++index) { - throw new ParserException("Context expected for claim id " + cid, 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( - "Claim context not defined in configuration: " + tok[index], src, linenr); - } // claim.setContext(context); - if (tok.length <= index + context.getAttributes().size()) { - throw new ParserException( - "Invalid number of context arguments: " + context.getContextName(), src, - linenr); - } - for (Attribute att : context.getAttributes()) { - claim.setAttribute(att.getAttributeName(), tok[++index]); - } - - addClaim(aTrace, cid, claim); - n_CLAIM++; - break; - - case DEPENDENCY_TAG: - index = 1; - - // Source ID - int sourceId = 0; - try { - sourceId = Integer.parseInt(tok[index]); - } catch (NumberFormatException e) { - throw new ParserException("Source ID has illegal value " + tok[index], src, - linenr); - } - claim = getClaim(sourceId); - if (claim == null) { - throw new ParserException("Source claim not known" + sourceId, src, linenr); - } - - // Sink ID - int sinkId = 0; - if (tok.length <= ++index) { - throw new ParserException("Sink ID expected ", src, linenr); - } - try { - sinkId = Integer.parseInt(tok[index]); - } catch (NumberFormatException e) { - throw new ParserException("Sink ID has illegal value " + tok[index], src, linenr); - } - claim = getClaim(sinkId); - if (claim == null) { - throw new ParserException("Sink claim not known" + sinkId, src, linenr); - } - - // Dependency Type - if (tok.length <= ++index) { - throw new ParserException("Dependency type expected ", src, linenr); - } - int dependencyType; - try { - dependencyType = Integer.parseInt(tok[index]); - } catch (NumberFormatException e) { - throw new ParserException("Dependency type has illegal value " + tok[index], src, - linenr); - } - DependencyType dType = DependencyType.get(dependencyType); - if (dType == null) { - throw new ParserException("Dependency type not known " + dependencyType, src, - linenr); - } - - // Dependency context - if (tok.length <= ++index) { - throw new ParserException("Context expected for dependency ", 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( - "Dependency context not defined in configuration: " + tok[index], src, - linenr); - } - if (tok.length <= index + context.getAttributes().size()) { - throw new ParserException( - "Invalid number of context arguments: " + context.getContextName(), src, - linenr); - } - - Claim srcClaim = getClaim(sourceId); - Claim dstClaim = getClaim(sinkId); - Dependency dependency = null; - switch (dType) { - case SOURCE_START2_SINK_START: - dependency = new Dependency(srcClaim.getStartEvent(), dstClaim.getStartEvent()); - break; - case SOURCE_START2_SINK_STOP: - dependency = new Dependency(srcClaim.getStartEvent(), dstClaim.getEndEvent()); - break; - case SOURCE_STOP2_SINK_START: - dependency = new Dependency(srcClaim.getEndEvent(), dstClaim.getStartEvent()); - break; - case SOURCE_STOP2_SINK_STOP: - dependency = new Dependency(srcClaim.getEndEvent(), dstClaim.getEndEvent()); + if (tok.length <= index + context.getAttributes().size()) { + throw new ParserException( + "Invalid number of context arguments: " + context.getContextName(), src, + linenr); + } + for (Attribute att: context.getAttributes()) { + claim.setAttribute(att.getAttributeName(), tok[++index]); + } + + addClaim(aTrace, cid, claim); break; - } - for (Attribute att : context.getAttributes()) { - dependency.setAttribute(att.getAttributeName(), tok[++index]); - } - addDependency(aTrace, dependency); - n_DEPENDENCY++; - break; + case DEPENDENCY_TAG: + index = 1; + + // Source ID + int sourceId = 0; + try { + sourceId = Integer.parseInt(tok[index]); + } catch (NumberFormatException e) { + throw new ParserException("Source ID has illegal value " + tok[index], src, linenr); + } + claim = getClaim(sourceId); + if (claim == null) { + throw new ParserException("Source claim not known" + sourceId, src, linenr); + } + + // Sink ID + int sinkId = 0; + if (tok.length <= ++index) { + throw new ParserException("Sink ID expected ", src, linenr); + } + try { + sinkId = Integer.parseInt(tok[index]); + } catch (NumberFormatException e) { + throw new ParserException("Sink ID has illegal value " + tok[index], src, linenr); + } + claim = getClaim(sinkId); + if (claim == null) { + throw new ParserException("Sink claim not known" + sinkId, src, linenr); + } - default: - throw new ParserException("Token not recognised " + tok[0], src, linenr); + // Dependency Type + if (tok.length <= ++index) { + throw new ParserException("Dependency type expected ", src, linenr); + } + int dependencyType; + try { + dependencyType = Integer.parseInt(tok[index]); + } catch (NumberFormatException e) { + throw new ParserException("Dependency type has illegal value " + tok[index], src, + linenr); + } + DependencyType dType = DependencyType.get(dependencyType); + if (dType == null) { + throw new ParserException("Dependency type not known " + dependencyType, src, linenr); + } + + // Dependency context + if (tok.length <= ++index) { + throw new ParserException("Context expected for dependency ", 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( + "Dependency context not defined in configuration: " + tok[index], src, linenr); + } + if (tok.length <= index + context.getAttributes().size()) { + throw new ParserException( + "Invalid number of context arguments: " + context.getContextName(), src, + linenr); + } + + Claim srcClaim = getClaim(sourceId); + Claim dstClaim = getClaim(sinkId); + Dependency dependency = null; + switch (dType) { + case SOURCE_START2_SINK_START: + dependency = new Dependency(srcClaim.getStartEvent(), dstClaim.getStartEvent()); + break; + case SOURCE_START2_SINK_STOP: + dependency = new Dependency(srcClaim.getStartEvent(), dstClaim.getEndEvent()); + break; + case SOURCE_STOP2_SINK_START: + dependency = new Dependency(srcClaim.getEndEvent(), dstClaim.getStartEvent()); + break; + case SOURCE_STOP2_SINK_STOP: + dependency = new Dependency(srcClaim.getEndEvent(), dstClaim.getEndEvent()); + break; + } + for (Attribute att: context.getAttributes()) { + dependency.setAttribute(att.getAttributeName(), tok[++index]); + } + + addDependency(aTrace, dependency); + break; + + default: + throw new ParserException("Token not recognised " + tok[0], src, linenr); } } else { if (!tok[0].isEmpty()) { @@ -616,10 +591,7 @@ public class ESIFormatTraceParser extends ESIFormatParser { if (n_CONFIGURATIONID == 0) { throw new ParserException("Missing required " + CONFIGURATIONID_TAG, src, 0); } - } finally { - reader.close(); } return; } - } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/LimitationsType.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/LimitationsType.java index 44c1177..bf0e8fc 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/LimitationsType.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/LimitationsType.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.io.conv; import java.util.Arrays; @@ -14,300 +15,262 @@ import java.util.Collections; import java.util.List; /** - * - * A representation of the literals of the enumeration 'Period Limitations Type', - * and utility methods for working with them. - * + * A representation of the literals of the enumeration 'Period Limitations Type', and utility methods + * for working with them. */ public enum LimitationsType { - /** - * The 'None' literal object. - * - * - * @see #NONE_VALUE - */ - NONE(0, "None", "None"), /** - * The 'Min Start' literal object. - * - * - * @see #MIN_START_VALUE - */ - MIN_START(1, "MinStart", "MinStart"), /** - * The 'Max Stop' literal object. - * - * - * @see #MAX_STOP_VALUE - */ - MAX_STOP(2, "MaxStop", "MaxStop"), /** - * The 'Min Start Max Stop' literal object. - * - * - * @see #MIN_START_MAX_STOP_VALUE - */ - MIN_START_MAX_STOP(3, "MinStart_MaxStop", "MinStart_MaxStop"), /** - * The 'Max Duration' literal object. - * - * - * @see #MAX_DURATION_VALUE - */ - MAX_DURATION(4, "MaxDuration", "MaxDuration"), /** - * The 'Min Start Max Duration' literal object. - * - * - * @see #MIN_START_MAX_DURATION_VALUE - */ - MIN_START_MAX_DURATION(5, "MinStart_MaxDuration", "MinStart_MaxDuration"), /** - * The 'Max Stop Max Duration' literal object. - * - * - * @see #MAX_STOP_MAX_DURATION_VALUE - */ - MAX_STOP_MAX_DURATION(6, "MaxStop_MaxDuration", "MaxStop_MaxDuration"), /** - * The 'Min Start Max Stop Max Duration' literal object. - * - * - * @see #MIN_START_MAX_STOP_MAX_DURATION_VALUE - */ - MIN_START_MAX_STOP_MAX_DURATION(7, "MinStart_MaxStop_MaxDuration", "MinStart_MaxStop_MaxDuration"); + /** + * The 'None' literal object. + * + * @see #NONE_VALUE + */ + NONE(0, "None", "None"), + /** + * The 'Min Start' literal object. + * + * @see #MIN_START_VALUE + */ + MIN_START(1, "MinStart", "MinStart"), + /** + * The 'Max Stop' literal object. + * + * @see #MAX_STOP_VALUE + */ + MAX_STOP(2, "MaxStop", "MaxStop"), + /** + * The 'Min Start Max Stop' literal object. + * + * @see #MIN_START_MAX_STOP_VALUE + */ + MIN_START_MAX_STOP(3, "MinStart_MaxStop", "MinStart_MaxStop"), + /** + * The 'Max Duration' literal object. + * + * @see #MAX_DURATION_VALUE + */ + MAX_DURATION(4, "MaxDuration", "MaxDuration"), + /** + * The 'Min Start Max Duration' literal object. + * + * @see #MIN_START_MAX_DURATION_VALUE + */ + MIN_START_MAX_DURATION(5, "MinStart_MaxDuration", "MinStart_MaxDuration"), + /** + * The 'Max Stop Max Duration' literal object. + * + * @see #MAX_STOP_MAX_DURATION_VALUE + */ + MAX_STOP_MAX_DURATION(6, "MaxStop_MaxDuration", "MaxStop_MaxDuration"), + /** + * The 'Min Start Max Stop Max Duration' literal object. + * + * @see #MIN_START_MAX_STOP_MAX_DURATION_VALUE + */ + MIN_START_MAX_STOP_MAX_DURATION(7, "MinStart_MaxStop_MaxDuration", "MinStart_MaxStop_MaxDuration"); - /** - * The 'None' literal value. - * - *

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

      - * - * @see #NONE - * @model name="None" - */ - public static final int NONE_VALUE = 0; + /** + * The 'None' literal value. + *

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

      + * + * @see #NONE + * @model name="None" + */ + public static final int NONE_VALUE = 0; - /** - * The 'Min Start' literal value. - * - *

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

      - * - * @see #MIN_START - * @model name="MinStart" - */ - public static final int MIN_START_VALUE = 1; + /** + * The 'Min Start' literal value. + *

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

      + * + * @see #MIN_START + * @model name="MinStart" + */ + public static final int MIN_START_VALUE = 1; - /** - * The 'Max Stop' literal value. - * - *

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

      - * - * @see #MAX_STOP - * @model name="MaxStop" - */ - public static final int MAX_STOP_VALUE = 2; + /** + * The 'Max Stop' literal value. + *

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

      + * + * @see #MAX_STOP + * @model name="MaxStop" + */ + public static final int MAX_STOP_VALUE = 2; - /** - * The 'Min Start Max Stop' literal value. - * - *

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

      - * - * @see #MIN_START_MAX_STOP - * @model name="MinStart_MaxStop" - */ - public static final int MIN_START_MAX_STOP_VALUE = 3; + /** + * The 'Min Start Max Stop' literal value. + *

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

      + * + * @see #MIN_START_MAX_STOP + * @model name="MinStart_MaxStop" + */ + public static final int MIN_START_MAX_STOP_VALUE = 3; - /** - * The 'Max Duration' literal value. - * - *

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

      - * - * @see #MAX_DURATION - * @model name="MaxDuration" - */ - public static final int MAX_DURATION_VALUE = 4; + /** + * The 'Max Duration' literal value. + *

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

      + * + * @see #MAX_DURATION + * @model name="MaxDuration" + */ + public static final int MAX_DURATION_VALUE = 4; - /** - * The 'Min Start Max Duration' literal value. - * - *

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

      - * - * @see #MIN_START_MAX_DURATION - * @model name="MinStart_MaxDuration" - */ - public static final int MIN_START_MAX_DURATION_VALUE = 5; + /** + * The 'Min Start Max Duration' literal value. + *

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

      + * + * @see #MIN_START_MAX_DURATION + * @model name="MinStart_MaxDuration" + */ + public static final int MIN_START_MAX_DURATION_VALUE = 5; - /** - * The 'Max Stop Max Duration' literal value. - * - *

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

      - * - * @see #MAX_STOP_MAX_DURATION - * @model name="MaxStop_MaxDuration" - */ - public static final int MAX_STOP_MAX_DURATION_VALUE = 6; + /** + * The 'Max Stop Max Duration' literal value. + *

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

      + * + * @see #MAX_STOP_MAX_DURATION + * @model name="MaxStop_MaxDuration" + */ + public static final int MAX_STOP_MAX_DURATION_VALUE = 6; - /** - * The 'Min Start Max Stop Max Duration' literal value. - * - *

      - * If the meaning of 'Min Start Max Stop Max Duration' literal object isn't clear, - * there really should be more of a description here... - *

      - * - * @see #MIN_START_MAX_STOP_MAX_DURATION - * @model name="MinStart_MaxStop_MaxDuration" - */ - public static final int MIN_START_MAX_STOP_MAX_DURATION_VALUE = 7; + /** + * The 'Min Start Max Stop Max Duration' literal value. + *

      + * If the meaning of 'Min Start Max Stop Max Duration' literal object isn't clear, there really + * should be more of a description here... + *

      + * + * @see #MIN_START_MAX_STOP_MAX_DURATION + * @model name="MinStart_MaxStop_MaxDuration" + */ + public static final int MIN_START_MAX_STOP_MAX_DURATION_VALUE = 7; - /** - * An array of all the 'Period Limitations Type' enumerators. - * - * - */ - private static final LimitationsType[] VALUES_ARRAY = - new LimitationsType[] { - NONE, - MIN_START, - MAX_STOP, - MIN_START_MAX_STOP, - MAX_DURATION, - MIN_START_MAX_DURATION, - MAX_STOP_MAX_DURATION, - MIN_START_MAX_STOP_MAX_DURATION, - }; + /** + * An array of all the 'Period Limitations Type' enumerators. + */ + private static final LimitationsType[] VALUES_ARRAY = new LimitationsType[] {NONE, MIN_START, MAX_STOP, + MIN_START_MAX_STOP, MAX_DURATION, MIN_START_MAX_DURATION, MAX_STOP_MAX_DURATION, + MIN_START_MAX_STOP_MAX_DURATION}; - /** - * A public read-only list of all the 'Period Limitations Type' enumerators. - * - * - */ - public static final List VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY)); + /** + * A public read-only list of all the 'Period Limitations Type' enumerators. + */ + public static final List VALUES = Collections.unmodifiableList(Arrays.asList(VALUES_ARRAY)); - /** - * Returns the 'Period Limitations Type' literal with the specified literal value. - * - * - */ - public static LimitationsType get(String literal) { - for (int i = 0; i < VALUES_ARRAY.length; ++i) { - LimitationsType result = VALUES_ARRAY[i]; - if (result.toString().equals(literal)) { - return result; - } - } - return null; - } + /** + * Returns the 'Period Limitations Type' literal with the specified literal value. + */ + public static LimitationsType get(String literal) { + for (int i = 0; i < VALUES_ARRAY.length; ++i) { + LimitationsType result = VALUES_ARRAY[i]; + if (result.toString().equals(literal)) { + return result; + } + } + return null; + } - /** - * Returns the 'Period Limitations Type' literal with the specified name. - * - * - */ - public static LimitationsType getByName(String name) { - for (int i = 0; i < VALUES_ARRAY.length; ++i) { - LimitationsType result = VALUES_ARRAY[i]; - if (result.getName().equals(name)) { - return result; - } - } - return null; - } + /** + * Returns the 'Period Limitations Type' literal with the specified name. + */ + public static LimitationsType getByName(String name) { + for (int i = 0; i < VALUES_ARRAY.length; ++i) { + LimitationsType result = VALUES_ARRAY[i]; + if (result.getName().equals(name)) { + return result; + } + } + return null; + } - /** - * Returns the 'Period Limitations Type' literal with the specified integer value. - * - * - */ - public static LimitationsType get(int value) { - switch (value) { - case NONE_VALUE: return NONE; - case MIN_START_VALUE: return MIN_START; - case MAX_STOP_VALUE: return MAX_STOP; - case MIN_START_MAX_STOP_VALUE: return MIN_START_MAX_STOP; - case MAX_DURATION_VALUE: return MAX_DURATION; - case MIN_START_MAX_DURATION_VALUE: return MIN_START_MAX_DURATION; - case MAX_STOP_MAX_DURATION_VALUE: return MAX_STOP_MAX_DURATION; - case MIN_START_MAX_STOP_MAX_DURATION_VALUE: return MIN_START_MAX_STOP_MAX_DURATION; - } - return null; - } + /** + * Returns the 'Period Limitations Type' literal with the specified integer value. + */ + public static LimitationsType get(int value) { + switch (value) { + case NONE_VALUE: + return NONE; + case MIN_START_VALUE: + return MIN_START; + case MAX_STOP_VALUE: + return MAX_STOP; + case MIN_START_MAX_STOP_VALUE: + return MIN_START_MAX_STOP; + case MAX_DURATION_VALUE: + return MAX_DURATION; + case MIN_START_MAX_DURATION_VALUE: + return MIN_START_MAX_DURATION; + case MAX_STOP_MAX_DURATION_VALUE: + return MAX_STOP_MAX_DURATION; + case MIN_START_MAX_STOP_MAX_DURATION_VALUE: + return MIN_START_MAX_STOP_MAX_DURATION; + } + return null; + } - /** - * - * - */ - private final int value; + /** + */ + private final int value; - /** - * - * - */ - private final String name; + /** + */ + private final String name; - /** - * - * - */ - private final String literal; + /** + */ + private final String literal; - /** - * Only this class can construct instances. - * - * - */ - private LimitationsType(int value, String name, String literal) { - this.value = value; - this.name = name; - this.literal = literal; - } + /** + * Only this class can construct instances. + */ + private LimitationsType(int value, String name, String literal) { + this.value = value; + this.name = name; + this.literal = literal; + } - /** - * - * - */ - public int getValue() { - return value; - } + /** + */ + public int getValue() { + return value; + } - /** - * - * - */ - public String getName() { - return name; - } + /** + */ + public String getName() { + return name; + } - /** - * - * - */ - public String getLiteral() { - return literal; - } + /** + */ + public String getLiteral() { + return literal; + } - /** - * Returns the literal value of the enumerator, which is its string representation. - * - * - */ - @Override - public String toString() { - return literal; - } - + /** + * Returns the literal value of the enumerator, which is its string representation. + */ + @Override + public String toString() { + return literal; + } } // PeriodLimitationsType diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/ParserException.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/ParserException.java index aa830e6..97b0cb4 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/ParserException.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/ParserException.java @@ -7,12 +7,12 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.io.conv; public class ParserException extends Exception { - /** - * + * */ private static final long serialVersionUID = 1L; @@ -44,5 +44,4 @@ public class ParserException extends Exception { public int getLinenr() { return linenr; } - } diff --git a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/TraceConverter.java b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/TraceConverter.java index 6759f63..d8e9cf2 100644 --- a/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/TraceConverter.java +++ b/trace/org.eclipse.trace4cps.core/src/org/eclipse/trace4cps/core/io/conv/TraceConverter.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.core.io.conv; import java.io.File; @@ -21,6 +22,12 @@ import org.eclipse.trace4cps.core.io.TraceWriter; * {@code java -classpath org.eclipse.trace4cps.core-?.?.?.jar org.eclipse.trace4cps.core.io.conv.TraceConverter } */ public class TraceConverter { + /** + * Private constructor prevents object creation. + */ + private TraceConverter() { + // Empty + } public static void main(String... args) { checkArgs(args); @@ -37,8 +44,7 @@ public class TraceConverter { } } - public static void convert(File configFile, File traceFile, File outputFile) - throws IOException, ParserException { + public static void convert(File configFile, File traceFile, File outputFile) throws IOException, ParserException { Configuration config = new ESIFormatConfigurationParser().parseTraceV0config(configFile); Trace trace = new ESIFormatTraceParser().parseTraceV0(traceFile, config); TraceWriter.writeTrace(trace, outputFile); @@ -54,7 +60,7 @@ public class TraceConverter { private static void checkArgs(String... args) { if (args.length != 2) { System.out.println( - "Usage: java -classpath org.eclipse.trace4cps.core-?.?.?.jar org.eclipse.trace4cps.core.io.conv.TraceConverter "); + "Usage: java -classpath org.eclipse.trace4cps.core-?.?.?.jar org.eclipse.trace4cps.core.io.conv.TraceConverter "); System.out.println("Given args: " + Arrays.toString(args)); System.exit(1); } diff --git a/trace/org.eclipse.trace4cps.ui.tests/.checkstyle b/trace/org.eclipse.trace4cps.ui.tests/.checkstyle new file mode 100644 index 0000000..b01fc54 --- /dev/null +++ b/trace/org.eclipse.trace4cps.ui.tests/.checkstyle @@ -0,0 +1,7 @@ + + + + + + + diff --git a/trace/org.eclipse.trace4cps.ui.tests/.project b/trace/org.eclipse.trace4cps.ui.tests/.project index 9b47504..4599057 100644 --- a/trace/org.eclipse.trace4cps.ui.tests/.project +++ b/trace/org.eclipse.trace4cps.ui.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.ui.tests/src/org/eclipse/trace4cps/ui/test/LogisticsCPAtest.java b/trace/org.eclipse.trace4cps.ui.tests/src/org/eclipse/trace4cps/ui/test/LogisticsCPAtest.java index 2de9320..e6ffc1d 100644 --- a/trace/org.eclipse.trace4cps.ui.tests/src/org/eclipse/trace4cps/ui/test/LogisticsCPAtest.java +++ b/trace/org.eclipse.trace4cps.ui.tests/src/org/eclipse/trace4cps/ui/test/LogisticsCPAtest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.ui.test; import java.awt.Paint; @@ -36,7 +37,6 @@ import org.eclipse.trace4cps.vis.jfree.TraceViewConfiguration; import org.junit.jupiter.api.Test; public class LogisticsCPAtest { - @Test public void testViewExample() { TraceHighlight hl = getExampleTrace(false); @@ -57,14 +57,13 @@ public class LogisticsCPAtest { @Test public void testViewExample2() throws PositiveCycleException { Trace t = createPaperPathTrace(20); - String[] ordering = new String[]{"PIM", "PIM to MP", "MP", "MP to ITS", "ITS", "ITS to DEF", "DEF", + String[] ordering = new String[] {"PIM", "PIM to MP", "MP", "MP to ITS", "ITS", "ITS to DEF", "DEF", "DEF to MP", "DEF to FIN", "FIN"}; ConstraintConfig cfg = ConstraintConfig.getDefault(); cfg.setAddSourceAndSink(true); cfg.setApplyOrderingHeuristic(0); CpaResult r = CriticalPathAnalysis.run(t, cfg); - showTrace(t, AnalysisUtil.createHighlight(r, null), ClaimScaling.RESOURCE_AMOUNT, - Arrays.asList(ordering)); + showTrace(t, AnalysisUtil.createHighlight(r, null), ClaimScaling.RESOURCE_AMOUNT, Arrays.asList(ordering)); } private Trace createPaperPathTrace(int numSheets) { @@ -87,8 +86,9 @@ public class LogisticsCPAtest { return trace; } - private void createSheetClaims(Trace trace, IResource r, IResource r2, double speed, double sheetLength, - double t, int i) { + private void createSheetClaims(Trace trace, IResource r, IResource r2, double speed, double sheetLength, double t, + int i) + { final double IN_MP = 1200; final double MP_ITS = 2300; final double ITS_DEF = 4000; @@ -224,7 +224,6 @@ public class LogisticsCPAtest { } else { return new TraceHighlight(trace); } - } private void showTrace(Trace trace, Map highlight) { @@ -232,7 +231,8 @@ public class LogisticsCPAtest { } private void showTrace(Trace trace, Map highlight, ClaimScaling scaling, - List order) { + List order) + { TracePlotManager mgr = new TracePlotManager(trace); TraceViewConfiguration cfg = mgr.getViewConfig(); cfg.setClaimScaling(scaling); @@ -254,14 +254,13 @@ public class LogisticsCPAtest { } private static final class TraceHighlight { - private final Trace trace; private final Set critical = new HashSet(); public TraceHighlight(Trace trace, IClaim... claims) { this.trace = trace; - for (IClaim c : claims) { + for (IClaim c: claims) { critical.add(c); } } diff --git a/trace/org.eclipse.trace4cps.ui.tests/src/org/eclipse/trace4cps/ui/test/PlotUtilTest.java b/trace/org.eclipse.trace4cps.ui.tests/src/org/eclipse/trace4cps/ui/test/PlotUtilTest.java index fcded70..193e959 100644 --- a/trace/org.eclipse.trace4cps.ui.tests/src/org/eclipse/trace4cps/ui/test/PlotUtilTest.java +++ b/trace/org.eclipse.trace4cps.ui.tests/src/org/eclipse/trace4cps/ui/test/PlotUtilTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.ui.test; import java.io.IOException; @@ -35,7 +36,6 @@ import org.jfree.data.xy.XYIntervalSeriesCollection; import org.junit.jupiter.api.Test; public class PlotUtilTest { - @Test public void testSimpleGantt() { TracePlotManager mgr = new TracePlotManager(getTestTrace()); @@ -80,7 +80,7 @@ public class PlotUtilTest { rs[i] = new Resource(1, false); rs[i].setAttribute("rid", "R" + Integer.toString(i)); } - Random rnd = new Random(0l); + Random rnd = new Random(0L); double t = 10; for (int i = 0; i < numTasks; i++) { double t0 = t + rnd.nextInt(10) - 5; @@ -99,7 +99,6 @@ public class PlotUtilTest { public static void showChart(final JFreeChart chart) { SwingUtilities.invokeLater(new Runnable() { - @Override public void run() { JFrame frame = new JFrame("Test plot"); @@ -120,7 +119,6 @@ public class PlotUtilTest { public static void showChart(final TracePlotManager mgr) { SwingUtilities.invokeLater(new Runnable() { - @Override public void run() { JFrame frame = new JFrame("Test plot"); @@ -128,17 +126,17 @@ public class PlotUtilTest { frame.setLocationRelativeTo(null); frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); frame.setVisible(true); - + JFreeChart chart = ChartFactory.createXYBarChart(null, null, false, null, - new XYIntervalSeriesCollection(), PlotOrientation.VERTICAL, false, true, false); + new XYIntervalSeriesCollection(), PlotOrientation.VERTICAL, false, true, false); XYPlot xyPlot = chart.getXYPlot(); // Setup the datasets and coloring etc of the plot: mgr.initializePlot(xyPlot); mgr.update(xyPlot); - + ChartPanel panel = new ChartPanel(chart); - + frame.setContentPane(panel); } }); diff --git a/trace/org.eclipse.trace4cps.ui.tests/src/org/eclipse/trace4cps/ui/test/STTTpaperTest.java b/trace/org.eclipse.trace4cps.ui.tests/src/org/eclipse/trace4cps/ui/test/STTTpaperTest.java index da6d249..d26b891 100644 --- a/trace/org.eclipse.trace4cps.ui.tests/src/org/eclipse/trace4cps/ui/test/STTTpaperTest.java +++ b/trace/org.eclipse.trace4cps.ui.tests/src/org/eclipse/trace4cps/ui/test/STTTpaperTest.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.ui.test; import static org.eclipse.trace4cps.analysis.mtl.MtlBuilder.F; @@ -36,6 +37,7 @@ import org.eclipse.trace4cps.analysis.mtl.AtomicProposition; import org.eclipse.trace4cps.analysis.mtl.DefaultAtomicProposition; 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.signal.SignalModifier; import org.eclipse.trace4cps.analysis.signal.SignalUtil; import org.eclipse.trace4cps.analysis.stl.StlBuilder; @@ -62,7 +64,6 @@ import org.jfree.chart.JFreeChart; import org.junit.jupiter.api.Test; public class STTTpaperTest { - private static final File TEST = new File("../../trace-examples/test.etf"); private static final File BF = new File("../../trace-examples/odse/model-bf.etf"); @@ -120,20 +121,20 @@ public class STTTpaperTest { } /** - * One way to show the highlight; using the {@link Util.getAtomicPropIndices()} does not work because - * there are cases where only A and not G is then highlighted. The algorithm could conclude that the - * property could never be satisfied (because of the F_[0,40] bound) without seeing G. + * One way to show the highlight, using the + * {@link MtlUtil#getAtomicPropIndices(org.eclipse.trace4cps.analysis.mtl.MtlResult)} does not work because there + * are cases where only A and not G is then highlighted. The algorithm could conclude that the property could never + * be satisfied (because of the F_[0,40] bound) without seeing G. */ @Test - public void testMTL1() - throws IOException, MtlException, InterruptedException, ExecutionException, ParseException { + public void testMTL1() throws IOException, MtlException, InterruptedException, ExecutionException, ParseException { IFilteredTrace trace = new ModifiableTrace(TraceReader.readTrace(BF)); 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, 35, false)))); phis.add(phi); } @@ -162,7 +163,6 @@ public class STTTpaperTest { config.setUseDependencies(false); DependencyProvider p = new DependencyProvider() { - @Override public boolean isApplicationDependency(IEvent src, IEvent dst) { String sn = src.getAttributeValue("name"); @@ -237,8 +237,7 @@ public class STTTpaperTest { trace1.addFilterAndRecalculate(TracePart.CLAIM, getODSEfilter()); TraceViewConfiguration cfg = getODSEActivityCfg(); cfg.setShowDependencies(false); - cfg.setHighlightMap( - AnalysisUtil.computeAnomalyHistogramHighlight(trace1, "id", Collections.singleton("name"))); + cfg.setHighlightMap(AnalysisUtil.computeAnomalyHistogramHighlight(trace1, "id", Collections.singleton("name"))); PlotUtilTest.showChart(new TracePlotManager(cfg, trace1)); } @@ -246,8 +245,8 @@ public class STTTpaperTest { public void testAnomalyRepresentatives() throws IOException, ParseException { IFilteredTrace trace1 = new ModifiableTrace(TraceReader.readTrace(BF)); trace1.addFilterAndRecalculate(TracePart.CLAIM, getODSEfilter()); - IAttributeFilter filter = - AnalysisUtil.computeBehavioralRepresentativeFilter(trace1, "id", Collections.singleton("name")); + IAttributeFilter filter = AnalysisUtil.computeBehavioralRepresentativeFilter(trace1, "id", + Collections.singleton("name")); trace1.clearFilter(TracePart.ALL); trace1.addFilterAndRecalculate(TracePart.CLAIM, filter); TraceViewConfiguration cfg = getODSEActivityCfg(); @@ -262,7 +261,7 @@ public class STTTpaperTest { resources.add(getResource(trace, "M1")); resources.add(getResource(trace, "M2")); JFreeChart chart = AnalysisUtil.createResourceUsageHistogramPlot(trace, resources, - Collections.singletonList("name"), false); + Collections.singletonList("name"), false); assertNotNull(chart); PlotUtilTest.showChart(chart); } @@ -273,7 +272,7 @@ public class STTTpaperTest { List resources = new ArrayList(); resources.add(getResource(trace, "CPU")); JFreeChart chart = AnalysisUtil.createResourceUtilizationPlot(trace, resources, true, - new SignalModifier(1, 100, TimeUnit.MILLISECONDS), true); + new SignalModifier(1, 100, TimeUnit.MILLISECONDS), true); PlotUtilTest.showChart(chart); } @@ -283,15 +282,15 @@ public class STTTpaperTest { List resources = new ArrayList(); resources.add(getResource(trace, "M1")); resources.add(getResource(trace, "M2")); - JFreeChart chart = - AnalysisUtil.createResourceUtilizationPlot(trace, resources, true, SignalModifier.NONE, true); + JFreeChart chart = AnalysisUtil.createResourceUtilizationPlot(trace, resources, true, SignalModifier.NONE, + true); assertNotNull(chart); PlotUtilTest.showChart(chart); } private IResource getResource(ITrace trace, String attributeValue) { - for (IResource r : trace.getResources()) { - for (String val : r.getAttributes().values()) { + for (IResource r: trace.getResources()) { + for (String val: r.getAttributes().values()) { if (val.equals(attributeValue)) { return r; } @@ -313,8 +312,8 @@ public class STTTpaperTest { public void testWipPlotConvolution() throws IOException, ParseException { IFilteredTrace trace = new ModifiableTrace(TraceReader.readTrace(BF)); trace.addFilterAndRecalculate(TracePart.CLAIM, getODSEfilter()); - JFreeChart chart = - AnalysisUtil.createWipPlot(trace, "id", "ids", new SignalModifier(1, 50, TimeUnit.MILLISECONDS)); + JFreeChart chart = AnalysisUtil.createWipPlot(trace, "id", "ids", + new SignalModifier(1, 50, TimeUnit.MILLISECONDS)); assertNotNull(chart); PlotUtilTest.showChart(chart); } @@ -323,8 +322,7 @@ public class STTTpaperTest { public void testLatencyPlot() throws IOException, ParseException { IFilteredTrace trace = new ModifiableTrace(TraceReader.readTrace(BF)); trace.addFilterAndRecalculate(TracePart.CLAIM, getODSEfilter()); - JFreeChart chart = - AnalysisUtil.createLatencyPlot(trace, "id", TimeUnit.MILLISECONDS, 0d, TimeUnit.SECONDS); + JFreeChart chart = AnalysisUtil.createLatencyPlot(trace, "id", TimeUnit.MILLISECONDS, 0d, TimeUnit.SECONDS); assertNotNull(chart); PlotUtilTest.showChart(chart); } @@ -343,9 +341,9 @@ public class STTTpaperTest { StlFormula phi4 = StlBuilder.G(phi3); System.out.println(phi4.getRho()); - JFreeChart chart = - AnalysisUtil.createChart(trace.getTimeUnit(), "rho", new String[]{"p", "phi1", "phi2", "phi3"}, p, - phi1.getSignal(), phi2.getSignal(), phi3.getSignal()); + JFreeChart chart = AnalysisUtil.createChart(trace.getTimeUnit(), "rho", + new String[] + {"p", "phi1", "phi2", "phi3"}, p, phi1.getSignal(), phi2.getSignal(), phi3.getSignal()); PlotUtilTest.showChart(chart); } @@ -368,7 +366,6 @@ public class STTTpaperTest { public static IAttributeFilter getFlowMPfilter() { return new IAttributeFilter() { - @Override public boolean include(IAttributeAware a) { return "MP".equals(a.getAttributeValue("name")); @@ -378,19 +375,17 @@ public class STTTpaperTest { public static IAttributeFilter getODSEfilter() { return new IAttributeFilter() { - @Override public boolean include(IAttributeAware a) { String name = a.getAttributeValue("name"); - return name != null && (name.equals("A") || name.equals("B") || name.equals("C") - || name.equals("D") || name.equals("E") || name.equals("F") || name.equals("G")); + return name != null && (name.equals("A") || name.equals("B") || name.equals("C") || name.equals("D") + || name.equals("E") || name.equals("F") || name.equals("G")); } }; } public static IAttributeFilter getODSEIdfilter(int max) { return new IAttributeFilter() { - @Override public boolean include(IAttributeAware a) { String idStr = a.getAttributeValue("id"); @@ -404,7 +399,6 @@ public class STTTpaperTest { public static IAttributeFilter negationFilter(IAttributeFilter f) { return new IAttributeFilter() { - @Override public boolean include(IAttributeAware a) { return !f.include(a); @@ -414,13 +408,12 @@ public class STTTpaperTest { public static IAttributeFilter getODSEMemoryfilter() { return new IAttributeFilter() { - @Override public boolean include(IAttributeAware a) { if (!(a instanceof IClaim)) { return false; } - IClaim c = (IClaim) a; + IClaim c = (IClaim)a; IResource r = c.getResource(); String name = r.getAttributeValue("name"); return "M1".equals(name) || "M2".equals(name); diff --git a/trace/org.eclipse.trace4cps.ui/.checkstyle b/trace/org.eclipse.trace4cps.ui/.checkstyle new file mode 100644 index 0000000..b01fc54 --- /dev/null +++ b/trace/org.eclipse.trace4cps.ui/.checkstyle @@ -0,0 +1,7 @@ + + + + + + + diff --git a/trace/org.eclipse.trace4cps.ui/.project b/trace/org.eclipse.trace4cps.ui/.project index 5cb3f33..014eae6 100644 --- a/trace/org.eclipse.trace4cps.ui/.project +++ b/trace/org.eclipse.trace4cps.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/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/AnalysisUtil.java b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/AnalysisUtil.java index f293fcc..5ebfffb 100644 --- a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/AnalysisUtil.java +++ b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/AnalysisUtil.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.ui; import java.awt.Paint; @@ -73,25 +74,23 @@ import org.jfree.data.xy.XYSeries; import org.jfree.data.xy.XYSeriesCollection; /** - * This is the top-level access point for analysis methods on execution traces. Results can typically be used - * with the {@link TracePlotManager} for visualization, or are already {@code JFreeChart} instances. + * This is the top-level access point for analysis methods on execution traces. Results can typically be used with the + * {@link TracePlotManager} for visualization, or are already {@code JFreeChart} instances. */ public class AnalysisUtil { - private AnalysisUtil() { } - public static Map createAPhighlight(List states, - List results) { + public static Map createAPhighlight(List states, List results) { Map highlightMap = new HashMap<>(); - for (MtlResult r : results) { + for (MtlResult r: results) { if (InformativePrefix.BAD == r.informative()) { Set aps = MtlUtil.getAtomicPropositions(r.getPhi()); - for (IEvent e : states) { - for (AtomicProposition ap : aps) { + for (IEvent e: states) { + for (AtomicProposition ap: aps) { if (e.satisfies(ap)) { if (e instanceof IClaimEvent) { - highlightMap.put(((IClaimEvent) e).getClaim(), ColorManager.RED_PURE.getColor()); + highlightMap.put(((IClaimEvent)e).getClaim(), ColorManager.RED_PURE.getColor()); } } } @@ -104,13 +103,13 @@ public class AnalysisUtil { public static Map createAPhighlight2(List states, List results) { // Create highlight: Map highlightMap = new HashMap(); - for (MtlResult r : results) { + for (MtlResult r: results) { if (InformativePrefix.BAD == r.informative()) { // Add all claims that match the atomic propositions in this formula - for (int i : MtlUtil.getAtomicPropIndices(r)) { + for (int i: MtlUtil.getAtomicPropIndices(r)) { IEvent e = states.get(i); if (e instanceof IClaimEvent) { - highlightMap.put(((IClaimEvent) e).getClaim(), ColorManager.RED_PURE.getColor()); + highlightMap.put(((IClaimEvent)e).getClaim(), ColorManager.RED_PURE.getColor()); } } } @@ -118,8 +117,9 @@ public class AnalysisUtil { return highlightMap; } - public static Map mtlCheck(ITrace trace, List phis, - boolean interpretAsPrefix) throws MtlException, InterruptedException, ExecutionException { + public static Map mtlCheck(ITrace trace, List phis, boolean interpretAsPrefix) + throws MtlException, InterruptedException, ExecutionException + { List states = trace.getEvents(); MtlFuture f = new MtlChecker().checkAll(states, phis, Collections.emptySet(), interpretAsPrefix); List results = f.get(); @@ -128,16 +128,16 @@ public class AnalysisUtil { public static Map createHighlight(CpaResult r, DependencyProvider p) { Map m = new HashMap<>(); - for (IDependency dep : r.getCriticalDeps()) { + for (IDependency dep: r.getCriticalDeps()) { if (dep.getSrc() instanceof IClaimEvent) { // don't overwrite RED_1 highlight - IClaim src = ((IClaimEvent) dep.getSrc()).getClaim(); + IClaim src = ((IClaimEvent)dep.getSrc()).getClaim(); if (m.get(src) == null) { m.put(src, ColorManager.DARK_RED.getColor()); } } if (dep.getDst() instanceof IClaimEvent) { - IClaim dst = ((IClaimEvent) dep.getDst()).getClaim(); + IClaim dst = ((IClaimEvent)dep.getDst()).getClaim(); if (m.get(dst) == null) { m.put(dst, ColorManager.DARK_RED.getColor()); } @@ -152,44 +152,43 @@ public class AnalysisUtil { return m; } - public static Map computeDiffHighlights(ITrace referenceTrace, - ITrace modelTrace) { + public static Map computeDiffHighlights(ITrace referenceTrace, ITrace modelTrace) { Map highlight = new HashMap<>(); computeDiffHighlights(referenceTrace, modelTrace, true, highlight); return highlight; } - public static Map computeDiffHighlights(ITrace referenceTrace, - ITrace... modelTraces) { + public static Map computeDiffHighlights(ITrace referenceTrace, ITrace... modelTraces) { Map highlight = new HashMap<>(); - for (ITrace modelTrace : modelTraces) { + for (ITrace modelTrace: modelTraces) { computeDiffHighlights(referenceTrace, modelTrace, false, highlight); } return highlight; } - public static long computeDiffHighlights(ITrace referenceTrace, ITrace modelTrace, - boolean annotateReference, Map highlight) { - DistanceResult val = DistanceAnalysis.distance(referenceTrace, modelTrace, - new DefaultRepresentation(), annotateReference); + public static long computeDiffHighlights(ITrace referenceTrace, ITrace modelTrace, boolean annotateReference, + Map highlight) + { + DistanceResult val = DistanceAnalysis.distance(referenceTrace, modelTrace, new DefaultRepresentation(), + annotateReference); int min = Integer.MAX_VALUE; int max = Integer.MIN_VALUE; - for (Integer v : val.getInterestCount().keySet()) { + for (Integer v: val.getInterestCount().keySet()) { min = Math.min(min, v); max = Math.max(max, v); } // TODO: This new algorithm uses ten shades of red for distance analysis, - // please test and check if documentation should be updated + // please test and check if documentation should be updated int range = max - min; - for (Map.Entry> e : val.getInterestCount().entrySet()) { + for (Map.Entry> e: val.getInterestCount().entrySet()) { Integer level = e.getKey(); - float weight = (float) (level - min) / (float) range; + float weight = (float)(level - min) / (float)range; ColorManager color = ColorManager.getShadeOfRed(weight); if (color != ColorManager.NON_HIGHLIGHT) { - for (IEvent event : e.getValue()) { + for (IEvent event: e.getValue()) { if (event instanceof ClaimEvent) { - highlight.put(((ClaimEvent) event).getClaim(), color.getColor()); + highlight.put(((ClaimEvent)event).getClaim(), color.getColor()); } } } @@ -198,29 +197,31 @@ public class AnalysisUtil { } public static IAttributeFilter computeBehavioralRepresentativeFilter(ITrace trace, String idAtt, - Set uniquenessAtts) { + Set uniquenessAtts) + { List events = trace.getEvents(); BehavioralPartition part = BehavioralAnalysis.partition(events, idAtt, uniquenessAtts); return BehavioralAnalysis.computeBehavioralRepresentativeFilter(part); } public static Map computeAnomalyHistogramHighlight(ITrace trace, String idAtt, - Set uniquenessAtts) { + Set uniquenessAtts) + { Map h = new HashMap<>(); List events = trace.getEvents(); BehavioralPartition part = BehavioralAnalysis.partition(events, idAtt, uniquenessAtts); List hist = BehavioralAnalysis.createBehavioralHistogram(part); Map objectIds2Paint = new HashMap(); int i = 2; - for (HistogramEntry he : hist) { - for (Integer id : he.getCentralObjectIds()) { + for (HistogramEntry he: hist) { + for (Integer id: he.getCentralObjectIds()) { objectIds2Paint.put(id, ColorManager.getAutomaticColor(i).getColor()); } i = i + 1; } - for (IEvent event : events) { + for (IEvent event: events) { if (event instanceof IClaimEvent) { - IClaim claim = ((IClaimEvent) event).getClaim(); + IClaim claim = ((IClaimEvent)event).getClaim(); String idAttValue = claim.getAttributeValue(idAtt); Integer objectId = Integer.parseInt(idAttValue); h.put(claim, objectIds2Paint.get(objectId)); @@ -237,19 +238,18 @@ public class AnalysisUtil { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); int i = 0; - for (HistogramEntry h : hist) { + for (HistogramEntry h: hist) { dataset.addValue(h.size(), "rowKey", "h" + i); tooltips.add(getToolTip(idAtt, h)); i++; } - JFreeChart chart = ChartFactory.createBarChart(null, "", "size", dataset, PlotOrientation.VERTICAL, - false, true, false); - CategoryPlot plot = (CategoryPlot) chart.getPlot(); + JFreeChart chart = ChartFactory.createBarChart(null, "", "size", dataset, PlotOrientation.VERTICAL, false, true, + false); + CategoryPlot plot = (CategoryPlot)chart.getPlot(); plot.setRangePannable(false); - BarRenderer renderer = (BarRenderer) plot.getRenderer(); + BarRenderer renderer = (BarRenderer)plot.getRenderer(); renderer.setBarPainter(new StandardBarPainter()); renderer.setDefaultToolTipGenerator(new CategoryToolTipGenerator() { - @Override public String generateToolTip(CategoryDataset dataset, int r, int c) { return tooltips.get(c); @@ -280,7 +280,7 @@ public class AnalysisUtil { } b.append("}
      "); // add common values - for (Map.Entry entry : e.getCommonAttributeValues().entrySet()) { + for (Map.Entry entry: e.getCommonAttributeValues().entrySet()) { b.append(entry.getKey()).append(" = ").append(entry.getValue()).append("
      "); } b.append(""); @@ -288,29 +288,31 @@ public class AnalysisUtil { } public static JFreeChart createResourceUsageHistogramPlot(ITrace trace, List selected, - Collection resourceDescriptionAtts, boolean cumulative) { + Collection resourceDescriptionAtts, boolean cumulative) + { Map> m = ResourceAnalysis.compute(trace, selected, cumulative); DefaultCategoryDataset dataset = createDataset(m, resourceDescriptionAtts); - JFreeChart chart = ChartFactory.createBarChart(null, "# of concurrent claims on resource", - "% of time", dataset, PlotOrientation.VERTICAL, true, true, false); - CategoryPlot plot = (CategoryPlot) chart.getPlot(); + JFreeChart chart = ChartFactory.createBarChart(null, "# of concurrent claims on resource", "% of time", dataset, + PlotOrientation.VERTICAL, true, true, false); + CategoryPlot plot = (CategoryPlot)chart.getPlot(); plot.setRangePannable(false); - BarRenderer renderer = (BarRenderer) plot.getRenderer(); + BarRenderer renderer = (BarRenderer)plot.getRenderer(); renderer.setBarPainter(new StandardBarPainter()); renderer.setMaximumBarWidth(100d); renderer.setMinimumBarLength(0d); return chart; } - public static JFreeChart createResourceUtilizationPlot(ITrace trace, List selected, - boolean useAmount, SignalModifier mod, boolean alsoShowInst) throws AnalysisException { + public static JFreeChart createResourceUtilizationPlot(ITrace trace, List selected, boolean useAmount, + SignalModifier mod, boolean alsoShowInst) throws AnalysisException + { String xAxisLabel = "Time (" + getStringFor(trace.getTimeUnit(), false) + ")"; String yAxisLabel = useAmount ? "Claimed amount" : "Number of parallel claims"; - JFreeChart chart = ChartFactory.createXYLineChart("", xAxisLabel, yAxisLabel, - new XYSeriesCollection(), PlotOrientation.VERTICAL, true, true, false); + JFreeChart chart = ChartFactory.createXYLineChart("", xAxisLabel, yAxisLabel, new XYSeriesCollection(), + PlotOrientation.VERTICAL, true, true, false); Map usage = new HashMap(); - for (IResource r : selected) { + for (IResource r: selected) { String rName = TraceHelper.getValues(r, false); IPsop p; if (useAmount) { @@ -320,8 +322,7 @@ public class AnalysisUtil { } String modSpec = "_inst"; if (mod.appliesConvolution()) { - modSpec = - "[w=" + mod.getWindowWidth() + " " + getStringFor(mod.getWindowTimeUnit(), false) + "]"; + modSpec = "[w=" + mod.getWindowWidth() + " " + getStringFor(mod.getWindowTimeUnit(), false) + "]"; } usage.put(rName + modSpec, p); if (mod.appliesConvolution() && alsoShowInst) { @@ -334,13 +335,13 @@ public class AnalysisUtil { usage.put(rName + "_inst", inst); } } - ((XYPlot) chart.getPlot()).setDataset(createPsopDataset(usage)); + ((XYPlot)chart.getPlot()).setDataset(createPsopDataset(usage)); return chart; } private static XYDataset createPsopDataset(Map usage) { XYSeriesCollection dataset = new XYSeriesCollection(); - for (Map.Entry e : usage.entrySet()) { + for (Map.Entry e: usage.entrySet()) { dataset.addSeries(createSeriesData(e.getKey(), e.getValue(), true, true)); } return dataset; @@ -367,9 +368,10 @@ public class AnalysisUtil { } private static DefaultCategoryDataset createDataset(Map> histos, - Collection resourceDescriptionAtts) { + Collection resourceDescriptionAtts) + { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); - for (Map.Entry> e : histos.entrySet()) { + for (Map.Entry> e: histos.entrySet()) { TreeMap values = e.getValue(); for (int i = 0; i <= values.lastKey(); i++) { Double d = values.get(i); @@ -383,39 +385,39 @@ public class AnalysisUtil { return dataset; } - public static JFreeChart createLatencyPlot(ITrace trace, String idAttribute, TimeUnit scaleUnit, - double windowWidth, TimeUnit windowUnit) { + public static JFreeChart createLatencyPlot(ITrace trace, String idAttribute, TimeUnit scaleUnit, double windowWidth, + TimeUnit windowUnit) + { IPsop lat = SignalUtil.getLatency(trace, idAttribute, scaleUnit, windowWidth, windowUnit); String yAxisLabel = "Latency (" + getStringFor(scaleUnit, false) + ")"; String xAxisLabel = "Time (" + getStringFor(trace.getTimeUnit(), false) + ")"; XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(createSeriesData("latency", lat, false, false)); - JFreeChart chart = ChartFactory.createXYLineChart("", xAxisLabel, yAxisLabel, dataset, - PlotOrientation.VERTICAL, false, true, false); + JFreeChart chart = ChartFactory.createXYLineChart("", xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, + false, true, false); return chart; - } - public static JFreeChart createWipPlot(ITrace trace, String idAttribute, String valueUnit, - SignalModifier mod) { + public static JFreeChart createWipPlot(ITrace trace, String idAttribute, String valueUnit, SignalModifier mod) { IPsop pd = SignalUtil.getWip(trace, idAttribute, mod); String yAxisLabel = "Wip (number of " + valueUnit + ")"; String xAxisLabel = "Time (" + getStringFor(trace.getTimeUnit(), false) + ")"; XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(createSeriesData("wip", pd, true, true)); - JFreeChart chart = ChartFactory.createXYLineChart("", xAxisLabel, yAxisLabel, dataset, - PlotOrientation.VERTICAL, false, true, false); + JFreeChart chart = ChartFactory.createXYLineChart("", xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, + false, true, false); return chart; - } public static JFreeChart createThroughputPlot(ITrace trace, String idAttribute, String valueUnit, - TimeUnit scaleUnit, double windowWidth, TimeUnit windowUnit) { + TimeUnit scaleUnit, double windowWidth, TimeUnit windowUnit) + { return createThroughputPlots(trace, idAttribute, valueUnit, scaleUnit, windowUnit, windowWidth); } public static JFreeChart createThroughputPlots(ITrace trace, String idAttribute, String valueUnit, - TimeUnit scaleUnit, TimeUnit windowUnit, double... windowWidth) { + TimeUnit scaleUnit, TimeUnit windowUnit, double... windowWidth) + { // ensure that all mods have the same scale factor IPsop[] tps = new IPsop[windowWidth.length]; String[] legendLabels = new String[windowWidth.length]; @@ -430,37 +432,20 @@ public class AnalysisUtil { return createTPplot(trace, idAttribute, valueUnit, scaleUnit, legendLabels, tps); } - private static TimeUnit getTimeUnitForS(double s) { - if (s == 1e-9) { - return TimeUnit.NANOSECONDS; - } else if (s == 1e-6) { - return TimeUnit.MICROSECONDS; - } else if (s == 1e-3) { - return TimeUnit.MILLISECONDS; - } else if (s == 1) { - return TimeUnit.SECONDS; - } else if (s == 60d) { - return TimeUnit.MINUTES; - } else if (s == 3600d) { - return TimeUnit.HOURS; - } - throw new IllegalStateException(); - } - - public static JFreeChart createChart(TimeUnit tu, String yAxisLabel, String[] legendLabels, - IPsop... psops) { + public static JFreeChart createChart(TimeUnit tu, String yAxisLabel, String[] legendLabels, IPsop... psops) { String xAxisLabel = "Time (" + getStringFor(tu, false) + ")"; XYSeriesCollection dataset = new XYSeriesCollection(); for (int i = 0; i < psops.length; i++) { dataset.addSeries(createSeriesData(legendLabels[i], psops[i], true, true)); } - JFreeChart chart = ChartFactory.createXYLineChart("", xAxisLabel, yAxisLabel, dataset, - PlotOrientation.VERTICAL, true, true, false); + JFreeChart chart = ChartFactory.createXYLineChart("", xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, + true, true, false); return chart; } - private static JFreeChart createTPplot(ITrace trace, String idAttribute, String valueUnit, - TimeUnit scaleUnit, String[] legendLabels, IPsop[] tps) { + private static JFreeChart createTPplot(ITrace trace, String idAttribute, String valueUnit, TimeUnit scaleUnit, + String[] legendLabels, IPsop[] tps) + { if (valueUnit == null) { valueUnit = idAttribute + "s"; } @@ -471,13 +456,14 @@ public class AnalysisUtil { for (int i = 0; i < tps.length; i++) { dataset.addSeries(createSeriesData(legendLabels[i], tps[i], true, true)); } - JFreeChart chart = ChartFactory.createXYLineChart("", xAxisLabel, yAxisLabel, dataset, - PlotOrientation.VERTICAL, true, true, false); + JFreeChart chart = ChartFactory.createXYLineChart("", xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, + true, true, false); return chart; } public static JFreeChart createEventTPplot(TimeUnit traceTimeUnit, List events, IInterval dom, - String valueUnit, TimeUnit scaleUnit, double windowWidth, TimeUnit windowUnit) { + String valueUnit, TimeUnit scaleUnit, double windowWidth, TimeUnit windowUnit) + { if (valueUnit == null) { valueUnit = "objects"; } @@ -493,8 +479,8 @@ public class AnalysisUtil { XYSeriesCollection dataset = new XYSeriesCollection(); dataset.addSeries(createSeriesData(legendLabel, tp, true, true)); - JFreeChart chart = ChartFactory.createXYLineChart("", xAxisLabel, yAxisLabel, dataset, - PlotOrientation.VERTICAL, true, true, false); + JFreeChart chart = ChartFactory.createXYLineChart("", xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, + true, true, false); return chart; } diff --git a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/ConsoleUtil.java b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/ConsoleUtil.java index e959669..b3b6fd7 100644 --- a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/ConsoleUtil.java +++ b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/ConsoleUtil.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.ui; import org.eclipse.ui.IWorkbench; @@ -22,7 +23,6 @@ import org.eclipse.ui.console.MessageConsole; import org.eclipse.ui.console.MessageConsoleStream; public class ConsoleUtil { - public static final String CONSOLE_NAME = "TRACE4CPS"; private ConsoleUtil() { @@ -32,7 +32,6 @@ public class ConsoleUtil { // run on the UI thread: final IWorkbench workbench = PlatformUI.getWorkbench(); workbench.getDisplay().asyncExec(new Runnable() { - @Override public void run() { MessageConsole myConsole = findConsole(); @@ -55,19 +54,19 @@ public class ConsoleUtil { MessageConsole myConsole = null; for (int i = 0; i < existing.length; i++) { if (CONSOLE_NAME.equals(existing[i].getName())) { - myConsole = (MessageConsole) existing[i]; + myConsole = (MessageConsole)existing[i]; break; } } if (myConsole == null) { myConsole = new MessageConsole(CONSOLE_NAME, null); - conMan.addConsoles(new IConsole[]{myConsole}); + conMan.addConsoles(new IConsole[] {myConsole}); } // Make the console visible: try { IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); String id = IConsoleConstants.ID_CONSOLE_VIEW; - IConsoleView view = (IConsoleView) page.showView(id); + IConsoleView view = (IConsoleView)page.showView(id); view.display(myConsole); } catch (PartInitException e) { // swallow... diff --git a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/FileSelectionUtil.java b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/FileSelectionUtil.java index 880d064..22310b7 100644 --- a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/FileSelectionUtil.java +++ b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/FileSelectionUtil.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.ui; import java.io.File; @@ -29,7 +30,6 @@ import org.eclipse.ui.model.WorkbenchLabelProvider; import org.eclipse.ui.views.navigator.ResourceComparator; public class FileSelectionUtil { - private FileSelectionUtil() { } @@ -46,20 +46,19 @@ public class FileSelectionUtil { } 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; } @@ -72,8 +71,8 @@ public class FileSelectionUtil { } 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; diff --git a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/TracePerspectiveFactory.java b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/TracePerspectiveFactory.java index b4beaa7..d76b7c1 100644 --- a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/TracePerspectiveFactory.java +++ b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/TracePerspectiveFactory.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.ui; import org.eclipse.debug.ui.IDebugUIConstants; @@ -18,7 +19,6 @@ import org.eclipse.ui.IPageLayout; import org.eclipse.ui.IPerspectiveFactory; public class TracePerspectiveFactory implements IPerspectiveFactory { - public static final String PERSPECTIVE_ID = "org.eclipse.trace4cps.ui.perspective"; /** @@ -43,22 +43,21 @@ public class TracePerspectiveFactory implements IPerspectiveFactory { String editorArea = layout.getEditorArea(); layout.setEditorAreaVisible(true); - IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT, (float) 0.15, editorArea); + IFolderLayout left = layout.createFolder("left", IPageLayout.LEFT, (float)0.15, editorArea); left.addView(IPageLayout.ID_PROJECT_EXPLORER); - IFolderLayout right = layout.createFolder("right", IPageLayout.RIGHT, (float) 0.85, editorArea); + IFolderLayout right = layout.createFolder("right", IPageLayout.RIGHT, (float)0.85, editorArea); right.addView(VerificationResultView.VIEW_ID); right.addView(TimingAnalysisView.VIEW_ID); - IFolderLayout leftBottom = layout.createFolder("leftBottom", IPageLayout.BOTTOM, (float) 0.7, "left"); + IFolderLayout leftBottom = layout.createFolder("leftBottom", IPageLayout.BOTTOM, (float)0.7, "left"); leftBottom.addView(IPageLayout.ID_OUTLINE); IFolderLayout bottom = layout.createFolder("bottom", IPageLayout.BOTTOM, 0.7f, editorArea); bottom.addView(IPageLayout.ID_PROP_SHEET); bottom.addView("org.eclipse.ui.console.ConsoleView"); - IFolderLayout rightBottom = - layout.createFolder("rightBottom", IPageLayout.RIGHT, (float) 0.5, "bottom"); + IFolderLayout rightBottom = layout.createFolder("rightBottom", IPageLayout.RIGHT, (float)0.5, "bottom"); rightBottom.addPlaceholder(ChartView.VIEW_ID + ":*"); } } diff --git a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/action/OpenTraceView.java b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/action/OpenTraceView.java index 0e70b8c..48467ef 100644 --- a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/action/OpenTraceView.java +++ b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/action/OpenTraceView.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.ui.action; import java.io.File; @@ -18,20 +19,16 @@ import org.eclipse.jface.action.IAction; import org.eclipse.jface.viewers.ISelection; import org.eclipse.jface.viewers.IStructuredSelection; import org.eclipse.trace4cps.ui.view.TraceView; -import org.eclipse.ui.IObjectActionDelegate; -import org.eclipse.ui.IWorkbenchPart; - -public class OpenTraceView implements IObjectActionDelegate { +import org.eclipse.ui.IActionDelegate; +public class OpenTraceView implements IActionDelegate { private IStructuredSelection selection; - private IWorkbenchPart targetPart; - @Override public void run(IAction action) { List files = new ArrayList<>(); - for (Object o : selection) { - IFile file = (IFile) o; + for (Object o: selection) { + IFile file = (IFile)o; File f = new File(file.getLocation().toFile().getAbsolutePath()); files.add(f); } @@ -41,12 +38,7 @@ public class OpenTraceView implements IObjectActionDelegate { @Override public void selectionChanged(IAction action, ISelection selection) { if (selection instanceof IStructuredSelection) { - this.selection = (IStructuredSelection) selection; + this.selection = (IStructuredSelection)selection; } } - - @Override - public void setActivePart(IAction action, IWorkbenchPart targetPart) { - this.targetPart = targetPart; - } } diff --git a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/AbstractListSelectionWizardPage.java b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/AbstractListSelectionWizardPage.java index 6bab62e..626c7f8 100644 --- a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/AbstractListSelectionWizardPage.java +++ b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/AbstractListSelectionWizardPage.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.ui.dialog; import java.util.ArrayList; @@ -31,10 +32,9 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Label; public abstract class AbstractListSelectionWizardPage extends WizardPage { - public enum SelectionMode { EXACTLY_ONE, AT_LEAST_ONE, ALWAYS - }; + } private CheckboxTableViewer listViewer; @@ -49,7 +49,7 @@ public abstract class AbstractListSelectionWizardPage extends WizardPage { protected List getSelection() { List result = new ArrayList<>(); if (hasSelection()) { - for (Object sel : listViewer.getCheckedElements()) { + for (Object sel: listViewer.getCheckedElements()) { result.add(sel.toString()); } } @@ -83,10 +83,9 @@ public abstract class AbstractListSelectionWizardPage extends WizardPage { listViewer = CheckboxTableViewer.newCheckList(contents, SWT.BORDER); listViewer.getTable().setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true)); listViewer.addSelectionChangedListener(new ISelectionChangedListener() { - @Override public void selectionChanged(SelectionChangedEvent event) { - CheckboxTableViewer source = (CheckboxTableViewer) event.getSource(); + CheckboxTableViewer source = (CheckboxTableViewer)event.getSource(); updatePageCompletionStatus(source); } }); @@ -119,7 +118,7 @@ public abstract class AbstractListSelectionWizardPage extends WizardPage { /** * Add the selection and deselection buttons to the dialog. - * + * * @param composite org.eclipse.swt.widgets.Composite */ private void addSelectionButtons(Composite composite) { @@ -135,7 +134,7 @@ public abstract class AbstractListSelectionWizardPage extends WizardPage { selectButton.setText("Select All"); SelectionListener listener = new SelectionAdapter() { - + @Override public void widgetSelected(SelectionEvent e) { listViewer.setAllChecked(true); listViewer.setSelection(listViewer.getSelection(), true); @@ -147,7 +146,7 @@ public abstract class AbstractListSelectionWizardPage extends WizardPage { deselectButton.setText("Deselect All"); listener = new SelectionAdapter() { - + @Override public void widgetSelected(SelectionEvent e) { listViewer.setAllChecked(false); listViewer.setSelection(listViewer.getSelection(), true); diff --git a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/BehaviorWizard.java b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/BehaviorWizard.java index 0d4b76c..1b2c65c 100644 --- a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/BehaviorWizard.java +++ b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/BehaviorWizard.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.ui.dialog; import java.util.ArrayList; @@ -25,7 +26,6 @@ import org.eclipse.trace4cps.core.TracePart; import org.eclipse.trace4cps.ui.view.TraceView; public class BehaviorWizard extends Wizard { - private final TraceView traceView; private String idAtt; @@ -39,7 +39,6 @@ public class BehaviorWizard extends Wizard { public BehaviorWizard(TraceView view) { this.traceView = view; setWindowTitle("Behavior settings"); - } public String getIdAttribute() { @@ -92,7 +91,7 @@ public class BehaviorWizard extends Wizard { } private boolean validateIdAtt(String idAtt) { - for (IClaim claim : traceView.getTrace().getClaims()) { + for (IClaim claim: traceView.getTrace().getClaims()) { String val = claim.getAttributeValue(idAtt); if (val == null || !val.matches("-?\\d+")) { return false; @@ -102,7 +101,6 @@ public class BehaviorWizard extends Wizard { } private static final class IdPage extends AbstractListSelectionWizardPage { - private final Collection atts; public IdPage(Wizard wizard, Collection atts) { @@ -127,7 +125,6 @@ public class BehaviorWizard extends Wizard { } private static final class UniquenessPage extends AbstractListSelectionWizardPage { - private final IdPage idPage; private final Collection atts; diff --git a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/CPAdialog.java b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/CPAdialog.java index 5b530a8..f4e317d 100644 --- a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/CPAdialog.java +++ b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/CPAdialog.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.ui.dialog; import org.eclipse.jface.dialogs.IDialogConstants; @@ -22,14 +23,13 @@ import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Shell; public final class CPAdialog extends ParameterDialog { - private static final String TITLE = "Critical path analysis"; private static final String USE_DEFAULT_EPSILON_KEY = "USE_DEFAULT_EPS"; public static enum DependencyUse { NONE, FULL, APP; - }; + } private DependencyUse depUse = DependencyUse.FULL; @@ -77,12 +77,10 @@ public final class CPAdialog extends ParameterDialog { epsilonGroup.setVisible(depUse != DependencyUse.FULL); - Button epsilonButton = - addCheckbox(epsilonGroup, "Use default epsilon", USE_DEFAULT_EPSILON_KEY, true); + Button epsilonButton = addCheckbox(epsilonGroup, "Use default epsilon", USE_DEFAULT_EPSILON_KEY, true); Composite epsilonInputGroup = addPositiveDoubleInput(epsilonGroup, null, true); epsilonInputGroup.setVisible(!get(USE_DEFAULT_EPSILON_KEY, Boolean.class)); epsilonButton.addSelectionListener(new SelectionAdapter() { - @Override public void widgetSelected(SelectionEvent e) { boolean useDefaultEpsilon = epsilonButton.getSelection(); @@ -106,7 +104,6 @@ public final class CPAdialog extends ParameterDialog { } b1.addSelectionListener(new SelectionAdapter() { - @Override public void widgetSelected(SelectionEvent e) { depUse = DependencyUse.NONE; @@ -115,7 +112,6 @@ public final class CPAdialog extends ParameterDialog { } }); b2.addSelectionListener(new SelectionAdapter() { - @Override public void widgetSelected(SelectionEvent e) { depUse = DependencyUse.FULL; @@ -124,7 +120,6 @@ public final class CPAdialog extends ParameterDialog { } }); b3.addSelectionListener(new SelectionAdapter() { - @Override public void widgetSelected(SelectionEvent e) { depUse = DependencyUse.APP; diff --git a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/DependencyAnalysisWizard.java b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/DependencyAnalysisWizard.java index 72eb1a4..50fb54f 100644 --- a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/DependencyAnalysisWizard.java +++ b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/DependencyAnalysisWizard.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.ui.dialog; import java.io.File; @@ -26,7 +27,6 @@ import org.eclipse.trace4cps.core.TracePart; import org.eclipse.trace4cps.ui.view.TraceView; public class DependencyAnalysisWizard extends Wizard { - private final TraceView traceView; private ModelTraceSelectionPage page1; @@ -95,7 +95,6 @@ public class DependencyAnalysisWizard extends Wizard { } private static final class ModelTraceSelectionPage extends AbstractListSelectionWizardPage { - private final Map fileNameToIndex = new HashMap<>(); private final List fileNames = new ArrayList<>(); @@ -140,7 +139,7 @@ public class DependencyAnalysisWizard extends Wizard { return -1; } String modelTraceName = selection.get(0); - for (Map.Entry e : fileNameToIndex.entrySet()) { + for (Map.Entry e: fileNameToIndex.entrySet()) { if (!modelTraceName.equals(e.getKey())) { return e.getValue(); } @@ -150,7 +149,6 @@ public class DependencyAnalysisWizard extends Wizard { } private static final class WeightAttributeSelectionPage extends AbstractListSelectionWizardPage { - private final List depAttributes; public WeightAttributeSelectionPage(DependencyAnalysisWizard wizard, Set attributeNames) { diff --git a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/DistanceDialog.java b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/DistanceDialog.java index 813eb2e..2271bed 100644 --- a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/DistanceDialog.java +++ b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/DistanceDialog.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.ui.dialog; import java.util.Map; @@ -15,7 +16,6 @@ import org.eclipse.swt.widgets.Composite; import org.eclipse.swt.widgets.Shell; public final class DistanceDialog extends ParameterDialog { - private static final String TITLE = "Distance analysis"; private final Map traceKeyToIndex; @@ -41,8 +41,7 @@ public final class DistanceDialog extends ParameterDialog { } protected void draw(final Composite composite) { - addSelectionInput(composite, "Select the reference trace", SelectionType.EXACTLY_ONE, - traceKeyToIndex.keySet()); + addSelectionInput(composite, "Select the reference trace", SelectionType.EXACTLY_ONE, traceKeyToIndex.keySet()); applyDialogFont(composite); } } diff --git a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/FilterWizard.java b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/FilterWizard.java index f700f20..9e172e6 100644 --- a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/FilterWizard.java +++ b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/FilterWizard.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.ui.dialog; import java.util.ArrayList; @@ -26,12 +27,10 @@ import org.eclipse.trace4cps.vis.jfree.TraceViewConfiguration.DisjunctionFilter; import org.eclipse.trace4cps.vis.jfree.TraceViewConfiguration.SimpleFilter; /** - * A wizard with a number of pages. First page selects the attribute names for which we want to define a - * filter. A wizard page is added for each of these attributes to select the value(s) that are included in the - * filter. + * A wizard with a number of pages. First page selects the attribute names for which we want to define a filter. A + * wizard page is added for each of these attributes to select the value(s) that are included in the filter. */ public class FilterWizard extends Wizard { - private final TraceView traceView; private final TracePart part; @@ -73,9 +72,9 @@ public class FilterWizard extends Wizard { addPage(page1); // Add pages for all attributes we have; only the ones that are selected on the first page are // actually used. - for (String att : allAttributes) { - FilterAttributeValueSelectionWizardPage valueSelectionPage = - new FilterAttributeValueSelectionWizardPage(this, att); + for (String att: allAttributes) { + FilterAttributeValueSelectionWizardPage valueSelectionPage = new FilterAttributeValueSelectionWizardPage( + this, att); addPage(valueSelectionPage); idPageMap.put(att, valueSelectionPage); } @@ -91,7 +90,7 @@ public class FilterWizard extends Wizard { return idPageMap.get(selectedAtts.get(0)); // page of the first selected attribute } } else { - FilterAttributeValueSelectionWizardPage p = (FilterAttributeValueSelectionWizardPage) page; + FilterAttributeValueSelectionWizardPage p = (FilterAttributeValueSelectionWizardPage)page; String currentAtt = p.getAttribute(); int index = selectedAtts.indexOf(currentAtt); if (index + 1 < selectedAtts.size()) { @@ -108,7 +107,7 @@ public class FilterWizard extends Wizard { if (!page1.hasSelection()) { return false; } - for (String att : page1.getSelection()) { + for (String att: page1.getSelection()) { FilterAttributeValueSelectionWizardPage page = idPageMap.get(att); if (!page.hasSelection()) { return false; @@ -120,7 +119,7 @@ public class FilterWizard extends Wizard { @Override public boolean performFinish() { DisjunctionFilter filter = new DisjunctionFilter(); - for (String att : page1.getSelection()) { + for (String att: page1.getSelection()) { FilterAttributeValueSelectionWizardPage page = idPageMap.get(att); List includedValues = page.getSelection(); filter.add(new SimpleFilter(att, includedValues)); @@ -130,7 +129,6 @@ public class FilterWizard extends Wizard { } private static final class FilterAttributeSelectionWizardPage extends AbstractListSelectionWizardPage { - public FilterAttributeSelectionWizardPage(FilterWizard wizard) { super("FilterAttributeSelectionWizardPage", wizard, SelectionMode.AT_LEAST_ONE); } @@ -147,13 +145,11 @@ public class FilterWizard extends Wizard { @Override protected Collection getInput() { - return ((FilterWizard) getWizard()).getAllAttributes(); + return ((FilterWizard)getWizard()).getAllAttributes(); } } - private static final class FilterAttributeValueSelectionWizardPage - extends AbstractListSelectionWizardPage { - + private static final class FilterAttributeValueSelectionWizardPage extends AbstractListSelectionWizardPage { private final String att; private final List attValues; @@ -161,8 +157,8 @@ public class FilterWizard extends Wizard { public FilterAttributeValueSelectionWizardPage(FilterWizard wizard, String att) { super("FilterAttributeValueSelectionWizardPage", wizard, SelectionMode.AT_LEAST_ONE); this.att = att; - Set values = ((FilterWizard) getWizard()).getTraceView().getAllAttributeValuesFor(att, - ((FilterWizard) getWizard()).getPart()); + Set values = ((FilterWizard)getWizard()).getTraceView().getAllAttributeValuesFor(att, + ((FilterWizard)getWizard()).getPart()); attValues = new ArrayList<>(); attValues.addAll(values); Collections.sort(attValues); diff --git a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/LittlesLawDialog.java b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/LittlesLawDialog.java index 4a6dce7..b733c00 100644 --- a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/LittlesLawDialog.java +++ b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/LittlesLawDialog.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.ui.dialog; import java.util.ArrayList; @@ -16,7 +17,6 @@ import java.util.List; import java.util.Map; import java.util.Set; -import org.eclipse.jface.dialogs.IDialogConstants; import org.eclipse.swt.SWT; import org.eclipse.swt.events.SelectionAdapter; import org.eclipse.swt.events.SelectionEvent; @@ -25,7 +25,6 @@ import org.eclipse.swt.layout.GridLayout; import org.eclipse.swt.widgets.Button; import org.eclipse.swt.widgets.Combo; import org.eclipse.swt.widgets.Composite; -import org.eclipse.swt.widgets.Control; import org.eclipse.swt.widgets.Group; import org.eclipse.swt.widgets.Label; import org.eclipse.swt.widgets.Shell; @@ -34,13 +33,9 @@ import org.eclipse.trace4cps.core.TracePart; import org.eclipse.trace4cps.ui.view.TraceView; public final class LittlesLawDialog extends ParameterDialog { - public enum LlDialogType { - - THROUGHPUT("identifier-based throughput"), - THROUGHPUT_EVENT("event-based throughput"), - LATENCY("identifier-based latency"), - WIP("identifier-based wip"); + THROUGHPUT("identifier-based throughput"), THROUGHPUT_EVENT("event-based throughput"), + LATENCY("identifier-based latency"), WIP("identifier-based wip"); private final String rep; @@ -51,7 +46,7 @@ public final class LittlesLawDialog extends ParameterDialog { public String getRepresentation() { return rep; } - }; + } private static final String TITLE = "Little's law analysis"; @@ -59,7 +54,7 @@ public final class LittlesLawDialog extends ParameterDialog { private final LlDialogType dialogType; - private final int N = 5; + private static final int N = 5; private final String[] keys = new String[N]; @@ -157,8 +152,7 @@ public final class LittlesLawDialog extends ParameterDialog { addTimeUnitDropdown(sub, "Value scale"); Set atts = traceView.getAttributeNames(TracePart.CLAIM); - addSelectionInput(main, "Select exactly one object grouping attribute", SelectionType.EXACTLY_ONE, - atts); + addSelectionInput(main, "Select exactly one object grouping attribute", SelectionType.EXACTLY_ONE, atts); } private void drawTPevent(Composite main) { @@ -172,7 +166,6 @@ public final class LittlesLawDialog extends ParameterDialog { } private void createFilterInput(Composite main) { - Group group1 = new Group(main, SWT.SHADOW_IN); group1.setText("Event type"); group1.setLayout(new GridLayout(3, true)); @@ -193,21 +186,18 @@ public final class LittlesLawDialog extends ParameterDialog { } b1.addSelectionListener(new SelectionAdapter() { - @Override public void widgetSelected(SelectionEvent e) { eventType = null; } }); b2.addSelectionListener(new SelectionAdapter() { - @Override public void widgetSelected(SelectionEvent e) { eventType = ClaimEventType.START; } }); b3.addSelectionListener(new SelectionAdapter() { - @Override public void widgetSelected(SelectionEvent e) { eventType = ClaimEventType.END; @@ -232,7 +222,6 @@ public final class LittlesLawDialog extends ParameterDialog { final Combo valCombo = new Combo(filterGroup, SWT.DROP_DOWN | SWT.READ_ONLY); keyCombo.setItems(input.toArray(new String[input.size()])); keyCombo.addSelectionListener(new SelectionAdapter() { - @Override public void widgetSelected(SelectionEvent e) { int idx = keyCombo.getSelectionIndex(); @@ -250,7 +239,6 @@ public final class LittlesLawDialog extends ParameterDialog { } }); valCombo.addSelectionListener(new SelectionAdapter() { - @Override public void widgetSelected(SelectionEvent e) { int idx = valCombo.getSelectionIndex(); @@ -273,8 +261,7 @@ public final class LittlesLawDialog extends ParameterDialog { addTimeUnitDropdown(sub, "Value scale"); Set atts = traceView.getAttributeNames(TracePart.CLAIM); - addSelectionInput(main, "Select exactly one object grouping attribute", SelectionType.EXACTLY_ONE, - atts); + addSelectionInput(main, "Select exactly one object grouping attribute", SelectionType.EXACTLY_ONE, atts); } private void drawWip(Composite main) { @@ -284,7 +271,6 @@ public final class LittlesLawDialog extends ParameterDialog { addPositiveDoubleInput(sub, true); Set atts = traceView.getAttributeNames(TracePart.CLAIM); - addSelectionInput(main, "Select exactly one object grouping attribute", SelectionType.EXACTLY_ONE, - atts); + addSelectionInput(main, "Select exactly one object grouping attribute", SelectionType.EXACTLY_ONE, atts); } } diff --git a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/ParameterDialog.java b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/ParameterDialog.java index 88d4f5f..45c2b50 100644 --- a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/ParameterDialog.java +++ b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/ParameterDialog.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.ui.dialog; import java.util.ArrayList; @@ -44,10 +45,9 @@ import org.eclipse.swt.widgets.Text; * An abstract class for dialogs that ask parameters from the user. */ public abstract class ParameterDialog extends Dialog { - enum SelectionType { EXACTLY_ONE, AT_LEAST_ONE - }; + } private static final Map> SETTINGS = new HashMap<>(); @@ -82,7 +82,7 @@ public abstract class ParameterDialog extends Dialog { @Override protected final Control createDialogArea(Composite parent) { - Composite composite = (Composite) super.createDialogArea(parent); + Composite composite = (Composite)super.createDialogArea(parent); composite.getShell().setText(getTitle()); draw(composite); return composite; @@ -143,7 +143,7 @@ public abstract class ParameterDialog extends Dialog { @SuppressWarnings("unchecked") T get(String key, Class clazz) { synchronized (LOCK) { - return (T) SETTINGS.get(settingsKey).get(key); + return (T)SETTINGS.get(settingsKey).get(key); } } @@ -172,7 +172,6 @@ public abstract class ParameterDialog extends Dialog { final Button cb = new Button(gr, SWT.CHECK); cb.setSelection(get(key, Boolean.class)); cb.addSelectionListener(new SelectionAdapter() { - @Override public void widgetSelected(SelectionEvent e) { set(key, cb.getSelection()); @@ -191,7 +190,7 @@ public abstract class ParameterDialog extends Dialog { Label lb = new Label(gr, SWT.HORIZONTAL); lb.setText(msg); final Combo cb = new Combo(gr, SWT.DROP_DOWN | SWT.READ_ONLY); - String[] items = new String[]{TimeUnit.MICROSECONDS.toString(), TimeUnit.MILLISECONDS.toString(), + String[] items = new String[] {TimeUnit.MICROSECONDS.toString(), TimeUnit.MILLISECONDS.toString(), TimeUnit.SECONDS.toString(), TimeUnit.MINUTES.toString(), TimeUnit.HOURS.toString(), TimeUnit.DAYS.toString()}; cb.setItems(items); @@ -203,7 +202,6 @@ public abstract class ParameterDialog extends Dialog { } } cb.addSelectionListener(new SelectionAdapter() { - @Override public void widgetSelected(SelectionEvent e) { int idx = cb.getSelectionIndex(); @@ -231,7 +229,6 @@ public abstract class ParameterDialog extends Dialog { text.setText(get(key, String.class)); text.setLayoutData(eData); text.addModifyListener(new ModifyListener() { - @Override public void modifyText(ModifyEvent e) { set(key, text.getText()); @@ -240,8 +237,8 @@ public abstract class ParameterDialog extends Dialog { } Composite addPositiveDoubleInput(Composite main, boolean includeZero) { - return addPositiveDoubleInput(main, - "Window width (" + TimeUnit.SECONDS.toString().toLowerCase() + ")", includeZero); + return addPositiveDoubleInput(main, "Window width (" + TimeUnit.SECONDS.toString().toLowerCase() + ")", + includeZero); } /** @@ -284,7 +281,7 @@ public abstract class ParameterDialog extends Dialog { errorMsg.setVisible(false); positiveDoubleInput.addModifyListener(new ModifyListener() { - + @Override public void modifyText(ModifyEvent e) { String s = positiveDoubleInput.getText(); positiveDoubleOk = true; @@ -313,8 +310,7 @@ public abstract class ParameterDialog extends Dialog { return inputGroup; } - void addSelectionInput(Composite main, String title, SelectionType selectionType, - Collection items) { + void addSelectionInput(Composite main, String title, SelectionType selectionType, Collection items) { this.selectionType = selectionType; if (!isSet(SELECTION_KEY)) { set(SELECTION_KEY, new ArrayList()); @@ -336,19 +332,17 @@ public abstract class ParameterDialog extends Dialog { List selection = get(SELECTION_KEY, List.class); cbtv.setCheckedElements(selection.toArray()); cbtv.setLabelProvider(new LabelProvider() { - @Override public String getText(Object element) { return element.toString(); } }); cbtv.addSelectionChangedListener(new ISelectionChangedListener() { - @Override public void selectionChanged(SelectionChangedEvent event) { - CheckboxTableViewer source = (CheckboxTableViewer) event.getSource(); + CheckboxTableViewer source = (CheckboxTableViewer)event.getSource(); List newSelection = new ArrayList(); - for (Object o : source.getCheckedElements()) { + for (Object o: source.getCheckedElements()) { newSelection.add(o.toString()); } set(SELECTION_KEY, newSelection); @@ -370,7 +364,7 @@ public abstract class ParameterDialog extends Dialog { Button selectButton = new Button(buttonComposite, SWT.NULL); selectButton.setText("Select all"); selectButton.addSelectionListener(new SelectionAdapter() { - + @Override public void widgetSelected(SelectionEvent e) { cbtv.setAllChecked(true); cbtv.setSelection(cbtv.getSelection(), true); @@ -380,7 +374,7 @@ public abstract class ParameterDialog extends Dialog { Button deselectButton = new Button(buttonComposite, SWT.NULL); deselectButton.setText("Deselect all"); deselectButton.addSelectionListener(new SelectionAdapter() { - + @Override public void widgetSelected(SelectionEvent e) { cbtv.setAllChecked(false); cbtv.setSelection(cbtv.getSelection(), true); diff --git a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/ResourceClientHistogramDialog.java b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/ResourceClientHistogramDialog.java index b1f02f3..de6137e 100644 --- a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/ResourceClientHistogramDialog.java +++ b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/dialog/ResourceClientHistogramDialog.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.ui.dialog; import java.util.ArrayList; @@ -24,11 +25,7 @@ import org.eclipse.swt.widgets.Shell; import org.eclipse.trace4cps.core.IResource; import org.eclipse.trace4cps.core.impl.TraceHelper; -/** - * - */ public final class ResourceClientHistogramDialog extends ParameterDialog { - private static final String TITLE = "Resource-usage analysis"; private static final String CUMULATIVE_KEY = "CUMULATIVE"; @@ -39,11 +36,10 @@ public final class ResourceClientHistogramDialog extends ParameterDialog { private final Map resourceMap = new HashMap<>(); - public ResourceClientHistogramDialog(Shell parentShell, Collection resources, - boolean isHistoDialog) { + public ResourceClientHistogramDialog(Shell parentShell, Collection resources, boolean isHistoDialog) { super(parentShell, ResourceClientHistogramDialog.class.getName()); this.isHistoDialog = isHistoDialog; - for (IResource r : resources) { + for (IResource r: resources) { resourceMap.put(TraceHelper.getValues(r, true), r); } } @@ -54,7 +50,7 @@ public final class ResourceClientHistogramDialog extends ParameterDialog { public List getSelected() { List r = new ArrayList<>(); - for (String s : getSelection()) { + for (String s: getSelection()) { r.add(resourceMap.get(s)); } return r; diff --git a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/view/ChartView.java b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/view/ChartView.java index 6236ece..8aa463a 100644 --- a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/view/ChartView.java +++ b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/view/ChartView.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.ui.view; import java.awt.Frame; @@ -27,7 +28,6 @@ import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; public class ChartView extends ViewPart { - public static final String VIEW_ID = ChartView.class.getName() + ".id"; private Frame frame; @@ -45,7 +45,6 @@ public class ChartView extends ViewPart { public void dispose() { try { SwingUtilities.invokeAndWait(new Runnable() { - @Override public void run() { frame.dispose(); @@ -63,14 +62,12 @@ public class ChartView extends ViewPart { public static synchronized void showChart(JFreeChart chart, String title, String tip) { final IWorkbench workbench = PlatformUI.getWorkbench(); workbench.getDisplay().asyncExec(new Runnable() { - @Override public void run() { try { - IWorkbenchPage page = - PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); - ChartView view = (ChartView) page.showView(ChartView.VIEW_ID, - Long.toHexString(System.currentTimeMillis()), IWorkbenchPage.VIEW_ACTIVATE); + IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage(); + ChartView view = (ChartView)page.showView(ChartView.VIEW_ID, + Long.toHexString(System.currentTimeMillis()), IWorkbenchPage.VIEW_ACTIVATE); view.setPartName(title); view.setTitleToolTip(tip); view.setResult(chart); diff --git a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/view/ClaimDataItem.java b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/view/ClaimDataItem.java index eed5099..c1c34a5 100644 --- a/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/view/ClaimDataItem.java +++ b/trace/org.eclipse.trace4cps.ui/src/org/eclipse/trace4cps/ui/view/ClaimDataItem.java @@ -7,6 +7,7 @@ * * SPDX-License-Identifier: EPL-2.0 */ + package org.eclipse.trace4cps.ui.view; import org.eclipse.trace4cps.common.jfreechart.ui.viewers.BackReferenceProvider; @@ -17,24 +18,23 @@ import org.jfree.data.xy.XYIntervalSeries; import org.jfree.data.xy.XYIntervalSeriesCollection; /** - * This is a data item for use with the JFreeChart {@code XYIntervalSeriesCollection} and - * {@code XYIntervalSeries} type. The methods {@code XYIntervalSeriesCollection#getSeries} and - * {@code XYIntervalSeries#getDataItem} can then be used to retrieve instances of this type. + * This is a data item for use with the JFreeChart {@code XYIntervalSeriesCollection} and {@code XYIntervalSeries} type. + * The methods {@code XYIntervalSeriesCollection#getSeries} and {@code XYIntervalSeries#getDataItem} can then be used to + * retrieve instances of this type. */ public class ClaimDataItem extends XYIntervalDataItem implements BackReferenceProvider { - private static final long serialVersionUID = 1L; - private final EclipseSelectionWrapper backReference; + private final EclipseSelectionWrapper backReference; public ClaimDataItem(IClaim claim, double xmin, double xmax, double ymin, double ymax) { - super((xmin + xmax) / 2, xmin, xmax, (ymin + ymax) / 2, ymin, ymax); - this.backReference = new EclipseSelectionWrapper(claim); + super((xmin + xmax) / 2, xmin, xmax, (ymin + ymax) / 2, ymin, ymax); + this.backReference = new EclipseSelectionWrapper(claim); } - + @Override public EclipseSelectionWrapper getBackReference() { - return backReference; + return backReference; } @Override @@ -44,11 +44,11 @@ public class ClaimDataItem extends XYIntervalDataItem implements BackReferencePr public static ClaimDataItem getFrom(XYDataset ds, int series, int item) { if (ds instanceof XYIntervalSeriesCollection) { - XYIntervalSeriesCollection sc = (XYIntervalSeriesCollection) ds; +