Changeset 34156 in osm for applications/editors/josm
- Timestamp:
- 2018-04-08T16:38:27+02:00 (7 years ago)
- Location:
- applications/editors/josm/plugins/CustomizePublicTransportStop
- Files:
-
- 2 added
- 14 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/CustomizePublicTransportStop/.project
r32329 r34156 21 21 </arguments> 22 22 </buildCommand> 23 <buildCommand> 24 <name>net.sf.eclipsecs.core.CheckstyleBuilder</name> 25 <arguments> 26 </arguments> 27 </buildCommand> 23 28 </buildSpec> 24 29 <natures> 25 30 <nature>org.eclipse.jdt.core.javanature</nature> 26 31 <nature>sf.eclipse.javacc.javaccnature</nature> 32 <nature>net.sf.eclipsecs.core.CheckstyleNature</nature> 27 33 </natures> 28 34 </projectDescription> -
applications/editors/josm/plugins/CustomizePublicTransportStop/.settings/org.eclipse.jdt.core.prefs
r32699 r34156 11 11 org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 12 12 org.eclipse.jdt.core.compiler.source=1.8 13 org.eclipse.jdt.core.formatter.align_fields_grouping_blank_lines=2147483647 14 org.eclipse.jdt.core.formatter.align_type_members_on_columns=false 15 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16 16 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_annotation=0 17 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16 18 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16 19 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16 20 org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16 21 org.eclipse.jdt.core.formatter.alignment_for_assignment=0 22 org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16 23 org.eclipse.jdt.core.formatter.alignment_for_compact_if=16 24 org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80 25 org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0 26 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16 27 org.eclipse.jdt.core.formatter.alignment_for_expressions_in_for_loop_header=0 28 org.eclipse.jdt.core.formatter.alignment_for_method_declaration=0 29 org.eclipse.jdt.core.formatter.alignment_for_module_statements=16 30 org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16 31 org.eclipse.jdt.core.formatter.alignment_for_parameterized_type_references=0 32 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16 33 org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16 34 org.eclipse.jdt.core.formatter.alignment_for_resources_in_try=80 35 org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16 36 org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16 37 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16 38 org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16 39 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16 40 org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16 41 org.eclipse.jdt.core.formatter.alignment_for_type_arguments=0 42 org.eclipse.jdt.core.formatter.alignment_for_type_parameters=0 43 org.eclipse.jdt.core.formatter.alignment_for_union_type_in_multicatch=16 44 org.eclipse.jdt.core.formatter.blank_lines_after_imports=1 45 org.eclipse.jdt.core.formatter.blank_lines_after_package=1 46 org.eclipse.jdt.core.formatter.blank_lines_before_field=0 47 org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0 48 org.eclipse.jdt.core.formatter.blank_lines_before_imports=1 49 org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1 50 org.eclipse.jdt.core.formatter.blank_lines_before_method=1 51 org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1 52 org.eclipse.jdt.core.formatter.blank_lines_before_package=0 53 org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1 54 org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1 55 org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line 56 org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line 57 org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line 58 org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line 59 org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line 60 org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line 61 org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line 62 org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line 63 org.eclipse.jdt.core.formatter.brace_position_for_lambda_body=end_of_line 64 org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line 65 org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line 66 org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line 67 org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false 68 org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false 69 org.eclipse.jdt.core.formatter.comment.count_line_length_from_starting_position=true 70 org.eclipse.jdt.core.formatter.comment.format_block_comments=true 71 org.eclipse.jdt.core.formatter.comment.format_header=false 72 org.eclipse.jdt.core.formatter.comment.format_html=true 73 org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true 74 org.eclipse.jdt.core.formatter.comment.format_line_comments=true 75 org.eclipse.jdt.core.formatter.comment.format_source_code=true 76 org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true 77 org.eclipse.jdt.core.formatter.comment.indent_root_tags=true 78 org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert 79 org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=do not insert 80 org.eclipse.jdt.core.formatter.comment.line_length=80 81 org.eclipse.jdt.core.formatter.comment.new_lines_at_block_boundaries=true 82 org.eclipse.jdt.core.formatter.comment.new_lines_at_javadoc_boundaries=true 83 org.eclipse.jdt.core.formatter.comment.preserve_white_space_between_code_and_line_comments=false 84 org.eclipse.jdt.core.formatter.compact_else_if=true 85 org.eclipse.jdt.core.formatter.continuation_indentation=2 86 org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2 87 org.eclipse.jdt.core.formatter.disabling_tag=@formatter\:off 88 org.eclipse.jdt.core.formatter.enabling_tag=@formatter\:on 89 org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false 90 org.eclipse.jdt.core.formatter.format_line_comment_starting_on_first_column=true 91 org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true 92 org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true 93 org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true 94 org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true 95 org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true 96 org.eclipse.jdt.core.formatter.indent_empty_lines=false 97 org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true 98 org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true 99 org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true 100 org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=false 101 org.eclipse.jdt.core.formatter.indentation.size=4 102 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_enum_constant=insert 103 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_field=insert 104 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert 105 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_method=insert 106 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_package=insert 107 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert 108 org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_type=insert 109 org.eclipse.jdt.core.formatter.insert_new_line_after_label=do not insert 110 org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert 111 org.eclipse.jdt.core.formatter.insert_new_line_after_type_annotation=do not insert 112 org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert 113 org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert 114 org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert 115 org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert 116 org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert 117 org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert 118 org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=insert 119 org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=insert 120 org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert 121 org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=insert 122 org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=insert 123 org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=insert 124 org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=insert 125 org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert 126 org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert 127 org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert 128 org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert 129 org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert 130 org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=do not insert 131 org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert 132 org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert 133 org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert 134 org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert 135 org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert 136 org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert 137 org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert 138 org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert 139 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert 140 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert 141 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert 142 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert 143 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert 144 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert 145 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert 146 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert 147 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert 148 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert 149 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert 150 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert 151 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert 152 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert 153 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert 154 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert 155 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert 156 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert 157 org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert 158 org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert 159 org.eclipse.jdt.core.formatter.insert_space_after_lambda_arrow=insert 160 org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert 161 org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert 162 org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert 163 org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=do not insert 164 org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert 165 org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert 166 org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert 167 org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert 168 org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert 169 org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert 170 org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert 171 org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert 172 org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert 173 org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert 174 org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert 175 org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert 176 org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert 177 org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert 178 org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_try=do not insert 179 org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert 180 org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert 181 org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert 182 org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert 183 org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert 184 org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert 185 org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_try_resources=insert 186 org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert 187 org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert 188 org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert 189 org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert 190 org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert 191 org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert 192 org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert 193 org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert 194 org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=do not insert 195 org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert 196 org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert 197 org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert 198 org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert 199 org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert 200 org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert 201 org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert 202 org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert 203 org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert 204 org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert 205 org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert 206 org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert 207 org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert 208 org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert 209 org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_try=do not insert 210 org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert 211 org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert 212 org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert 213 org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert 214 org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert 215 org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert 216 org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert 217 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert 218 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert 219 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert 220 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert 221 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert 222 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert 223 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert 224 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert 225 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert 226 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert 227 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert 228 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert 229 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert 230 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert 231 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert 232 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert 233 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert 234 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert 235 org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert 236 org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert 237 org.eclipse.jdt.core.formatter.insert_space_before_lambda_arrow=insert 238 org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert 239 org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert 240 org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert 241 org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert 242 org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert 243 org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert 244 org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert 245 org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert 246 org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert 247 org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert 248 org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert 249 org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert 250 org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert 251 org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert 252 org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert 253 org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert 254 org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert 255 org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert 256 org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert 257 org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert 258 org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert 259 org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert 260 org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert 261 org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert 262 org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert 263 org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert 264 org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert 265 org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert 266 org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_try=insert 267 org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert 268 org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert 269 org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert 270 org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert 271 org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert 272 org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert 273 org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert 274 org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert 275 org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert 276 org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_try_resources=do not insert 277 org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert 278 org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert 279 org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert 280 org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert 281 org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert 282 org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert 283 org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert 284 org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert 285 org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert 286 org.eclipse.jdt.core.formatter.join_lines_in_comments=true 287 org.eclipse.jdt.core.formatter.join_wrapped_lines=true 288 org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false 289 org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false 290 org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false 291 org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false 292 org.eclipse.jdt.core.formatter.lineSplit=120 293 org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false 294 org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false 295 org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0 296 org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1 297 org.eclipse.jdt.core.formatter.parentheses_positions_in_annotation=common_lines 298 org.eclipse.jdt.core.formatter.parentheses_positions_in_catch_clause=common_lines 299 org.eclipse.jdt.core.formatter.parentheses_positions_in_enum_constant_declaration=common_lines 300 org.eclipse.jdt.core.formatter.parentheses_positions_in_for_statment=common_lines 301 org.eclipse.jdt.core.formatter.parentheses_positions_in_if_while_statement=common_lines 302 org.eclipse.jdt.core.formatter.parentheses_positions_in_lambda_declaration=common_lines 303 org.eclipse.jdt.core.formatter.parentheses_positions_in_method_delcaration=common_lines 304 org.eclipse.jdt.core.formatter.parentheses_positions_in_method_invocation=common_lines 305 org.eclipse.jdt.core.formatter.parentheses_positions_in_switch_statement=common_lines 306 org.eclipse.jdt.core.formatter.parentheses_positions_in_try_clause=common_lines 307 org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true 308 org.eclipse.jdt.core.formatter.tabulation.char=space 309 org.eclipse.jdt.core.formatter.tabulation.size=4 310 org.eclipse.jdt.core.formatter.use_on_off_tags=false 311 org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false 312 org.eclipse.jdt.core.formatter.wrap_before_assignment_operator=false 313 org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true 314 org.eclipse.jdt.core.formatter.wrap_before_conditional_operator=true 315 org.eclipse.jdt.core.formatter.wrap_before_or_operator_multicatch=true 316 org.eclipse.jdt.core.formatter.wrap_outer_expressions_when_nested=true 317 org.eclipse.jdt.core.javaFormatter=org.eclipse.jdt.core.defaultJavaFormatter -
applications/editors/josm/plugins/CustomizePublicTransportStop/src/ru/rodsoft/openstreetmap/josm/plugins/customizepublictransportstop/CreateNewStopPointOperation.java
r33811 r34156 1 // License: GPL. For details, see LICENSE file. 1 2 package ru.rodsoft.openstreetmap.josm.plugins.customizepublictransportstop; 2 3 … … 24 25 25 26 /** 27 * Operation of creation of new stop point 26 28 * 27 29 * @author Rodion Scherbakov 28 * Operation of creation of new stop point29 30 */ 30 public class CreateNewStopPointOperation extends StopAreaOperationBase 31 { 32 33 /** 34 * Constructor of operation object 35 * @param currentDataSet Current Josm data set 36 */ 37 public CreateNewStopPointOperation(DataSet currentDataSet) 38 { 39 super(currentDataSet); 40 } 41 42 /** 43 * The *result* does not depend on the current map selection state, 44 * neither does the result *order*. 45 * It solely depends on the distance to point p. 31 public class CreateNewStopPointOperation extends StopAreaOperationBase { 32 33 /** 34 * Constructor of operation object 35 * 36 * @param currentDataSet Current Josm data set 37 */ 38 public CreateNewStopPointOperation(DataSet currentDataSet) { 39 super(currentDataSet); 40 } 41 42 /** 43 * The *result* does not depend on the current map selection state, neither does 44 * the result *order*. It solely depends on the distance to point p. 46 45 * 47 46 * This code is coped from JOSM code 48 47 * 49 * @return a sorted map with the keys representing the distance of 50 * theirassociated nodes to point p.48 * @return a sorted map with the keys representing the distance of their 49 * associated nodes to point p. 51 50 */ 52 51 private Map<Double, List<Node>> getNearestNodesImpl(Point p) { … … 59 58 60 59 for (Node n : ds.searchNodes(getBBox(p, 200))) { 61 if ((dist = MainApplication.getMap().mapView.getPoint2D(n).distanceSq(p)) < snapDistanceSq) 62 { 60 if ((dist = MainApplication.getMap().mapView.getPoint2D(n).distanceSq(p)) < snapDistanceSq) { 63 61 List<Node> nlist; 64 62 if (nearestMap.containsKey(dist)) { … … 78 76 /** 79 77 * Selection of area for search of roads 78 * 80 79 * @param p Current point 81 80 * @param snapDistance Distance for search … … 85 84 MapView mapView = MainApplication.getMap().mapView; 86 85 return new BBox(mapView.getLatLon(p.x - snapDistance, p.y - snapDistance), 87 mapView.getLatLon(p.x + snapDistance, p.y + snapDistance)); 88 } 89 90 /** 91 * Search of nearest points on ways 92 * @param platformCoord Platform coordinates 86 mapView.getLatLon(p.x + snapDistance, p.y + snapDistance)); 87 } 88 89 /** 90 * Search of nearest points on ways 91 * 92 * @param platformCoord Platform coordinates 93 93 * @param stopArea Stop area object 94 94 * @return Dictionary of founded points and distances from platform 95 95 */ 96 public AbstractMap.SimpleEntry<Double, Node> getNearestNode(LatLon platformCoord, StopArea stopArea) 97 { 98 Point p = MainApplication.getMap().mapView.getPoint(platformCoord); 99 Map<Double, List<Node>> dist_nodes = getNearestNodesImpl(p); 100 Double[] distances = dist_nodes.keySet().toArray(new Double[0]); 101 distances = sort(distances); 102 Integer distanceIndex = -1; 103 Node nearestNode = null; 104 while(++distanceIndex < distances.length && nearestNode == null) 105 { 106 List<Node> nodes = dist_nodes.get(distances[distanceIndex]); 107 for(Node node : nodes) 108 { 109 for(Way way : getCurrentDataSet().getWays()) 110 { 111 if(way.getNodes().contains(node) && testWay(way, stopArea)) 112 { 113 nearestNode = node; 114 return new AbstractMap.SimpleEntry<Double, Node> (distances[distanceIndex], nearestNode); 115 } 116 } 117 if(nearestNode != null) 118 break; 119 } 120 } 121 return null; 96 public AbstractMap.SimpleEntry<Double, Node> getNearestNode(LatLon platformCoord, StopArea stopArea) { 97 Point p = MainApplication.getMap().mapView.getPoint(platformCoord); 98 Map<Double, List<Node>> dist_nodes = getNearestNodesImpl(p); 99 Double[] distances = dist_nodes.keySet().toArray(new Double[0]); 100 distances = sort(distances); 101 Integer distanceIndex = -1; 102 Node nearestNode = null; 103 while (++distanceIndex < distances.length && nearestNode == null) { 104 List<Node> nodes = dist_nodes.get(distances[distanceIndex]); 105 for (Node node : nodes) { 106 for (Way way : getCurrentDataSet().getWays()) { 107 if (way.getNodes().contains(node) && testWay(way, stopArea)) { 108 nearestNode = node; 109 return new AbstractMap.SimpleEntry<Double, Node>(distances[distanceIndex], nearestNode); 110 } 111 } 112 if (nearestNode != null) 113 break; 114 } 115 } 116 return null; 122 117 } 123 118 124 119 /** 125 120 * Sorting of founded points by distance 121 * 126 122 * @param distances Array of distances 127 123 * @return Sorted array of distances 128 124 */ 129 public Double[] sort(Double[] distances) 130 { 131 for(Integer i = 0; i < distances.length - 1; i++) 132 for(Integer j = i + 1; j < distances.length; j++) 133 { 134 if(distances[i]>distances[j]) 135 { 136 Double d = distances[i]; 137 distances[i] = distances[j]; 138 distances[j] = d; 139 } 140 } 141 return distances; 142 } 143 125 public Double[] sort(Double[] distances) { 126 for (Integer i = 0; i < distances.length - 1; i++) { 127 for (Integer j = i + 1; j < distances.length; j++) { 128 if (distances[i] > distances[j]) { 129 Double d = distances[i]; 130 distances[i] = distances[j]; 131 distances[j] = d; 132 } 133 } 134 } 135 return distances; 136 } 137 144 138 /** 145 139 * Selection of ways for stop position by type of way and type of stop 140 * 146 141 * @param way The way 147 142 * @param stopArea Stop area 148 143 * @return true, if way can contain stop position 149 144 */ 150 public Boolean testWay(Way way, StopArea stopArea) 151 { 152 if(stopArea.isTrainStation || stopArea.isTrainStop) 153 { 154 if(OSMTags.RAIL_TAG_VALUE.equals(way.getKeys().get(OSMTags.RAILWAY_TAG)) && OSMTags.MAIN_TAG_VALUE.equals(way.getKeys().get(OSMTags.USAGE_TAG))) 155 return true; 156 return false; 157 } 158 159 if(stopArea.isTram) 160 { 161 if(OSMTags.TRAM_TAG_VALUE.equals(way.getKeys().get(OSMTags.RAILWAY_TAG))) 162 return true; 163 return false; 164 } 165 166 String[] highwayValues = {OSMTags.TRUNK_TAG_VALUE, OSMTags.PRIMARY_TAG_VALUE, OSMTags.SECONDARY_TAG_VALUE, OSMTags.TERTIARY_TAG_VALUE, 167 OSMTags.UNCLASSIFIED_TAG_VALUE, OSMTags.RESIDENTIAL_TAG_VALUE, OSMTags.SERVICE_TAG_VALUE, 168 OSMTags.BUS_GUIDEWAY_TAG_VALUE, OSMTags.ROAD_TAG_VALUE, OSMTags.TRUNK_LINK_TAG_VALUE, 169 OSMTags.PRIMARY_LINK_TAG_VALUE, OSMTags.SECONDARY_LINK_TAG_VALUE, OSMTags.TERTIARY_LINK_TAG_VALUE }; 170 if(stopArea.isBus || stopArea.isTrolleybus || stopArea.isShareTaxi) 171 { 172 String highway = way.getKeys().get(OSMTags.HIGHWAY_TAG); 173 if(highway != null) 174 for(Integer i = 0; i < highwayValues.length; i++) 175 { 176 if(highwayValues[i].equals(highway)) 177 return true; 178 } 179 } 180 return false; 181 } 182 183 /** 184 * The *result* does not depend on the current map selection state, 185 * neither does the result *order*. 186 * It solely depends on the distance to point p. 145 public Boolean testWay(Way way, StopArea stopArea) { 146 if (stopArea.isTrainStation || stopArea.isTrainStop) { 147 if (OSMTags.RAIL_TAG_VALUE.equals(way.getKeys().get(OSMTags.RAILWAY_TAG)) 148 && OSMTags.MAIN_TAG_VALUE.equals(way.getKeys().get(OSMTags.USAGE_TAG))) 149 return true; 150 return false; 151 } 152 153 if (stopArea.isTram) { 154 if (OSMTags.TRAM_TAG_VALUE.equals(way.getKeys().get(OSMTags.RAILWAY_TAG))) 155 return true; 156 return false; 157 } 158 159 String[] highwayValues = {OSMTags.TRUNK_TAG_VALUE, OSMTags.PRIMARY_TAG_VALUE, OSMTags.SECONDARY_TAG_VALUE, 160 OSMTags.TERTIARY_TAG_VALUE, OSMTags.UNCLASSIFIED_TAG_VALUE, OSMTags.RESIDENTIAL_TAG_VALUE, 161 OSMTags.SERVICE_TAG_VALUE, OSMTags.BUS_GUIDEWAY_TAG_VALUE, OSMTags.ROAD_TAG_VALUE, 162 OSMTags.TRUNK_LINK_TAG_VALUE, OSMTags.PRIMARY_LINK_TAG_VALUE, OSMTags.SECONDARY_LINK_TAG_VALUE, 163 OSMTags.TERTIARY_LINK_TAG_VALUE}; 164 if (stopArea.isBus || stopArea.isTrolleybus || stopArea.isShareTaxi) { 165 String highway = way.getKeys().get(OSMTags.HIGHWAY_TAG); 166 if (highway != null) 167 for (Integer i = 0; i < highwayValues.length; i++) { 168 if (highwayValues[i].equals(highway)) 169 return true; 170 } 171 } 172 return false; 173 } 174 175 /** 176 * The *result* does not depend on the current map selection state, neither does 177 * the result *order*. It solely depends on the distance to point p. 187 178 * 188 179 * This code is coped from JOSM code 189 180 * 190 * @return a sorted map with the keys representing the perpendicular 191 * distance oftheir associated way segments to point p.181 * @return a sorted map with the keys representing the perpendicular distance of 182 * their associated way segments to point p. 192 183 */ 193 184 private Map<Double, List<WaySegment>> getNearestWaySegmentsImpl(Point p) { … … 204 195 for (Node n : w.getNodes()) { 205 196 i++; 206 if (n.isDeleted() || n.isIncomplete()) { //FIXME: This shouldn't happen, raise exception? 197 if (n.isDeleted() || n.isIncomplete()) { // FIXME: This shouldn't happen, raise exception? 207 198 continue; 208 199 } … … 218 209 double b = p.distanceSq(A); 219 210 220 /* perpendicular distance squared 221 * loose some precision to account for possible deviations in the calculation above 222 * e.g. if identical (A and B) come about reversed in another way, values may differ 223 * -- zero out least significant 32 dual digits of mantissa.. 211 /* 212 * perpendicular distance squared loose some precision to account for possible 213 * deviations in the calculation above e.g. if identical (A and B) come about 214 * reversed in another way, values may differ -- zero out least significant 32 215 * dual digits of mantissa.. 224 216 */ 225 217 double perDistSq = Double.longBitsToDouble( 226 Double.doubleToLongBits( a - (a - b + c) * (a - b + c) / 4 / c )227 >> 32 << 32); // resolution in numbers with large exponent not needed here..218 // resolution in numbers with large exponent not needed here.. 219 Double.doubleToLongBits(a - (a - b + c) * (a - b + c) / 4 / c) >> 32 << 32); 228 220 229 221 if (perDistSq < snapDistanceSq && a < c + snapDistanceSq && b < c + snapDistanceSq) { … … 245 237 return nearestMap; 246 238 } 247 239 248 240 /** 249 241 * Selection of nearest way for stop position 242 * 250 243 * @param platformCoord Platform coordinates 251 244 * @param stopArea Stop area 252 245 * @return Nearest way segment 253 246 */ 254 protected NearestWaySegment getNearestWaySegment(LatLon platformCoord, StopArea stopArea) 255 { 247 protected NearestWaySegment getNearestWaySegment(LatLon platformCoord, StopArea stopArea) { 256 248 MapView mapView = MainApplication.getMap().mapView; 257 Point p = mapView.getPoint(platformCoord); 258 Map<Double, List<WaySegment>> dist_waySegments = getNearestWaySegmentsImpl(p); 259 for(Map.Entry<Double, List<WaySegment>> entry : dist_waySegments.entrySet()) 260 { 261 for(WaySegment waySegment : entry.getValue()) 262 { 263 if(testWay(waySegment.way, stopArea)) 264 { 265 Node n = waySegment.getFirstNode(); 266 Node lastN = waySegment.getSecondNode(); 267 268 EastNorth newPosition = Geometry.closestPointToSegment(n.getEastNorth(), 269 lastN.getEastNorth(), Main.getProjection().latlon2eastNorth(platformCoord)); 270 LatLon newNodePosition = Main.getProjection().eastNorth2latlon(newPosition); 271 Point2D lastN2D = mapView.getPoint2D(lastN); 272 Point2D n2D = mapView.getPoint2D(n); 273 Point2D newNodePosition2D = mapView.getPoint2D(newNodePosition); 274 Double distCurrenNodes =lastN2D.distance(n2D); 275 if((newNodePosition2D.distance(lastN2D) < distCurrenNodes) && (newNodePosition2D.distance(n2D) < distCurrenNodes)) 276 { 277 return new NearestWaySegment(entry.getKey(), waySegment, new Node(newNodePosition)); 278 } 279 } 280 } 281 } 282 return null; 249 Point p = mapView.getPoint(platformCoord); 250 Map<Double, List<WaySegment>> dist_waySegments = getNearestWaySegmentsImpl(p); 251 for (Map.Entry<Double, List<WaySegment>> entry : dist_waySegments.entrySet()) { 252 for (WaySegment waySegment : entry.getValue()) { 253 if (testWay(waySegment.way, stopArea)) { 254 Node n = waySegment.getFirstNode(); 255 Node lastN = waySegment.getSecondNode(); 256 257 EastNorth newPosition = Geometry.closestPointToSegment(n.getEastNorth(), lastN.getEastNorth(), 258 Main.getProjection().latlon2eastNorth(platformCoord)); 259 LatLon newNodePosition = Main.getProjection().eastNorth2latlon(newPosition); 260 Point2D lastN2D = mapView.getPoint2D(lastN); 261 Point2D n2D = mapView.getPoint2D(n); 262 Point2D newNodePosition2D = mapView.getPoint2D(newNodePosition); 263 Double distCurrenNodes = lastN2D.distance(n2D); 264 if ((newNodePosition2D.distance(lastN2D) < distCurrenNodes) 265 && (newNodePosition2D.distance(n2D) < distCurrenNodes)) { 266 return new NearestWaySegment(entry.getKey(), waySegment, new Node(newNodePosition)); 267 } 268 } 269 } 270 } 271 return null; 283 272 } 284 273 285 274 /** 286 275 * Creation of stop position node on nearest way 276 * 287 277 * @param newStopNode New stop position node 288 278 * @param waySegment Way segment including stop position node 289 279 * @return Stop position node 290 280 */ 291 protected Node createNodeOnWay(Node newStopNode, WaySegment waySegment) 292 { 293 Main.main.undoRedo.add(new AddCommand(MainApplication.getLayerManager().getEditDataSet(), newStopNode)); 294 List<Node> wayNodes = waySegment.way.getNodes(); 295 wayNodes.add(waySegment.lowerIndex + 1, newStopNode); 296 Way newWay = new Way(waySegment.way); 297 newWay.setNodes(wayNodes); 298 Main.main.undoRedo.add(new ChangeCommand(waySegment.way, newWay)); 299 return newStopNode; 281 protected Node createNodeOnWay(Node newStopNode, WaySegment waySegment) { 282 Main.main.undoRedo.add(new AddCommand(MainApplication.getLayerManager().getEditDataSet(), newStopNode)); 283 List<Node> wayNodes = waySegment.way.getNodes(); 284 wayNodes.add(waySegment.lowerIndex + 1, newStopNode); 285 Way newWay = new Way(waySegment.way); 286 newWay.setNodes(wayNodes); 287 Main.main.undoRedo.add(new ChangeCommand(waySegment.way, newWay)); 288 return newStopNode; 300 289 } 301 290 302 291 /** 303 292 * Creation of stop position 293 * 304 294 * @param stopArea Stop Area 305 295 */ 306 296 @Override 307 public StopArea performCustomizing(StopArea stopArea) 308 { 309 LatLon platformCoord = null; 310 if(stopArea.selectedObject instanceof Node) 311 { 312 platformCoord = ((Node) stopArea.selectedObject).getCoor(); 313 } 314 else 315 platformCoord = getCenterOfWay(stopArea.selectedObject); 316 if(platformCoord == null) 317 return stopArea; 318 AbstractMap.SimpleEntry<Double, Node> nearestNode = getNearestNode(platformCoord, stopArea); 319 NearestWaySegment nearestWaySegment = getNearestWaySegment(platformCoord, stopArea); 320 Node newStopPointNode = null; 321 if(nearestNode != null && nearestWaySegment != null) 322 { 323 MapView mapView = MainApplication.getMap().mapView; 324 Double segmentDist = mapView.getPoint2D(platformCoord).distanceSq(mapView.getPoint2D(nearestWaySegment.newNode)); 325 Double nodeDistSq = nearestNode.getKey(); 326 // nodeDistSq *= nodeDistSq - 2; 327 if(segmentDist < nodeDistSq - 2) 328 { 329 // MessageBox.ok("new stop node v2 " + segmentDist.toString() + " " + nodeDistSq.toString()); 330 newStopPointNode = createNodeOnWay(nearestWaySegment.newNode, nearestWaySegment.waySegment); 331 } 332 else 333 { 334 // MessageBox.ok("new stop node v3 " + segmentDist.toString() + " " + nodeDistSq.toString()); 335 newStopPointNode = nearestNode.getValue(); 336 } 337 } 338 else 339 if(nearestNode != null && nearestWaySegment == null) 340 { 341 newStopPointNode = nearestNode.getValue(); 342 } 343 else 344 if(nearestNode == null && nearestWaySegment != null) 345 { 346 // MessageBox.ok("new stop node2"); 347 newStopPointNode = createNodeOnWay(nearestWaySegment.newNode, nearestWaySegment.waySegment); 348 } 349 if(newStopPointNode != null) 350 { 351 stopArea.stopPoints.add(newStopPointNode); 352 } 353 return stopArea; 354 } 355 297 public StopArea performCustomizing(StopArea stopArea) { 298 LatLon platformCoord = null; 299 if (stopArea.selectedObject instanceof Node) { 300 platformCoord = ((Node) stopArea.selectedObject).getCoor(); 301 } else 302 platformCoord = getCenterOfWay(stopArea.selectedObject); 303 if (platformCoord == null) 304 return stopArea; 305 AbstractMap.SimpleEntry<Double, Node> nearestNode = getNearestNode(platformCoord, stopArea); 306 NearestWaySegment nearestWaySegment = getNearestWaySegment(platformCoord, stopArea); 307 Node newStopPointNode = null; 308 if (nearestNode != null && nearestWaySegment != null) { 309 MapView mapView = MainApplication.getMap().mapView; 310 Double segmentDist = mapView.getPoint2D(platformCoord) 311 .distanceSq(mapView.getPoint2D(nearestWaySegment.newNode)); 312 Double nodeDistSq = nearestNode.getKey(); 313 // nodeDistSq *= nodeDistSq - 2; 314 if (segmentDist < nodeDistSq - 2) { 315 // MessageBox.ok("new stop node v2 " + segmentDist.toString() + " " + 316 // nodeDistSq.toString()); 317 newStopPointNode = createNodeOnWay(nearestWaySegment.newNode, nearestWaySegment.waySegment); 318 } else { 319 // MessageBox.ok("new stop node v3 " + segmentDist.toString() + " " + 320 // nodeDistSq.toString()); 321 newStopPointNode = nearestNode.getValue(); 322 } 323 } else if (nearestNode != null && nearestWaySegment == null) { 324 newStopPointNode = nearestNode.getValue(); 325 } else if (nearestNode == null && nearestWaySegment != null) { 326 // MessageBox.ok("new stop node2"); 327 newStopPointNode = createNodeOnWay(nearestWaySegment.newNode, nearestWaySegment.waySegment); 328 } 329 if (newStopPointNode != null) { 330 stopArea.stopPoints.add(newStopPointNode); 331 } 332 return stopArea; 333 } 334 356 335 } -
applications/editors/josm/plugins/CustomizePublicTransportStop/src/ru/rodsoft/openstreetmap/josm/plugins/customizepublictransportstop/CreateStopAreaFromSelectedObjectOperation.java
r32840 r34156 1 // License: GPL. For details, see LICENSE file. 1 2 package ru.rodsoft.openstreetmap.josm.plugins.customizepublictransportstop; 2 3 … … 11 12 12 13 /** 14 * Operation of constructing of stop area object from selected JOSM object 13 15 * 14 16 * @author Rodion Scherbakov 15 * Operation of constructing of stop area object from selected JOSM object16 17 */ 17 public class CreateStopAreaFromSelectedObjectOperation extends 18 StopAreaOperationBase 19 { 18 public class CreateStopAreaFromSelectedObjectOperation extends StopAreaOperationBase { 20 19 21 22 23 * @param currentDataSet Current Josm data set 24 */ 25 public CreateStopAreaFromSelectedObjectOperation(DataSet currentDataSet) 26 27 28 20 /** 21 * Constructor of operation object 22 * 23 * @param currentDataSet Current Josm data set 24 */ 25 public CreateStopAreaFromSelectedObjectOperation(DataSet currentDataSet) { 26 super(currentDataSet); 27 } 29 28 30 /** 31 * Parsing of josm object tags and customizing of stop area object 32 * @param member Josm object 33 */ 34 public void parseTags(StopArea stopArea, OsmPrimitive member) 35 { 36 if(stopArea.name == null) 37 stopArea.name = getTagValue(member, OSMTags.NAME_TAG); 38 if(stopArea.nameEn == null) 39 stopArea.nameEn = getTagValue(member, OSMTags.NAME_EN_TAG); 40 if(stopArea.operator == null) 41 stopArea.operator = getTagValue(member, OSMTags.OPERATOR_TAG); 42 if(stopArea.network == null) 43 stopArea.network = getTagValue(member, OSMTags.NETWORK_TAG); 44 if(stopArea.service == null) 45 stopArea.service = getTagValue(member, OSMTags.SERVICE_TAG); 46 if(OSMTags.LOCAL_NETWORK_TAG_VALUE.equals(stopArea.service)) 47 stopArea.service = OSMTags.COMMUTER_NETWORK_TAG_VALUE; 48 if(compareTag(member, OSMTags.BUS_TAG, OSMTags.YES_TAG_VALUE)) 49 stopArea.isBus = true; 50 if(compareTag(member, OSMTags.TROLLEYBUS_TAG, OSMTags.YES_TAG_VALUE)) 51 stopArea.isTrolleybus = true; 52 if(compareTag(member, OSMTags.SHARE_TAXI_TAG, OSMTags.YES_TAG_VALUE)) 53 stopArea.isShareTaxi = true; 54 if(!(stopArea.isBus || stopArea.isShareTaxi || stopArea.isTrolleybus) && compareTag(member, OSMTags.HIGHWAY_TAG, OSMTags.BUS_STOP_TAG_VALUE)) 55 stopArea.isBus = true; 56 if(compareTag(member, OSMTags.TRAM_TAG, OSMTags.YES_TAG_VALUE) || compareTag(member, OSMTags.RAILWAY_TAG, OSMTags.TRAM_STOP_TAG_VALUE)) 57 stopArea.isTram = true; 58 if(compareTag(member, OSMTags.RAILWAY_TAG, OSMTags.HALT_TAG_VALUE)) 59 stopArea.isTrainStop = true; 60 if(compareTag(member, OSMTags.RAILWAY_TAG, OSMTags.STATION_TAG_VALUE)) 61 stopArea.isTrainStation = true; 62 if(compareTag(member, OSMTags.AMENITY_TAG, OSMTags.BUS_STATION_TAG_VALUE)) 63 { 64 stopArea.isBusStation = true; 65 } 66 if(member == stopArea.selectedObject) 67 { 68 if(compareTag(member, OSMTags.BENCH_TAG, OSMTags.YES_TAG_VALUE)) 69 stopArea.isBench = true; 70 if(compareTag(member, OSMTags.SHELTER_TAG, OSMTags.YES_TAG_VALUE)) 71 stopArea.isShelter = true; 72 if(compareTag(member, OSMTags.COVERED_TAG, OSMTags.YES_TAG_VALUE)) 73 stopArea.isCovered = true; 74 if(compareTag(member, OSMTags.AREA_TAG, OSMTags.YES_TAG_VALUE)) 75 stopArea.isArea = true; 76 } 77 } 78 79 /** 80 * Test, are transport types assigned to platforms 81 * @param platform Platform object 82 * @return true, if transport types assigned to this platforms 83 */ 84 public boolean testIsTransportTypeAssigned(OsmPrimitive platform) 85 { 86 String[] transportTypes = new String[] { OSMTags.BUS_TAG, OSMTags.TROLLEYBUS_TAG, OSMTags.SHARE_TAXI_TAG, OSMTags.TRAM_TAG, OSMTags.TRAIN_TAG }; 87 for(String transportType : transportTypes) 88 { 89 if(compareTag(platform, transportType, OSMTags.YES_TAG_VALUE)) 90 return true; 91 } 92 return false; 93 } 94 95 /** 96 * Setting of stop area from selected josm object 97 * @param selectedObject Selected josm object 98 */ 99 public void fromSelectedObject(StopArea stopArea) 100 { 101 Collection<OsmPrimitive> selectedObjects = new ArrayList<OsmPrimitive>(); 102 selectedObjects.add(stopArea.selectedObject); 103 for(Relation rel : OsmPrimitive.getParentRelations(selectedObjects)) 104 { 105 if(compareTag(rel, OSMTags.TYPE_TAG, OSMTags.PUBLIC_TRANSPORT_TAG) && compareTag(rel, OSMTags.PUBLIC_TRANSPORT_TAG, OSMTags.STOP_AREA_TAG_VALUE)) 106 { 107 stopArea.stopAreaRelation = rel; 108 } 109 if(stopArea.stopAreaRelation != null) 110 break; 111 } 112 113 if(stopArea.stopAreaRelation != null) 114 { 115 parseTags(stopArea, stopArea.stopAreaRelation); 116 parseTags(stopArea, stopArea.selectedObject); 117 for(RelationMember member : stopArea.stopAreaRelation.getMembers()) 118 { 119 if(member.getMember() instanceof Node && compareTag(member.getMember(), OSMTags.PUBLIC_TRANSPORT_TAG, OSMTags.STOP_POSITION_TAG_VALUE)) 120 { 121 stopArea.isStopPointExists = true; 122 stopArea.stopPoints.add(member.getNode()); 123 } 124 else 125 if(compareTag(member.getMember(), OSMTags.PUBLIC_TRANSPORT_TAG, OSMTags.PLATFORM_TAG_VALUE)) 126 { 127 stopArea.platforms.add(member.getMember()); 128 } 129 else 130 { 131 stopArea.otherMembers.add(member.getMember()); 132 } 133 parseTags(stopArea, member.getMember()); 134 } 135 if(!stopArea.platforms.contains(stopArea.selectedObject)) 136 { 137 parseTags(stopArea, stopArea.selectedObject); 138 stopArea.platforms.add(stopArea.selectedObject); 139 } 140 } 141 else 142 { 143 parseTags(stopArea, stopArea.selectedObject); 144 stopArea.platforms.add(stopArea.selectedObject); 145 } 146 for(OsmPrimitive platform : stopArea.platforms) 147 { 148 if(testIsTransportTypeAssigned(platform)) 149 { 150 stopArea.isAssignTransportType = true; 151 break; 152 } 153 } 154 if(!(stopArea.isBus || stopArea.isTrolleybus || stopArea.isShareTaxi) && stopArea.selectedObject != null && (compareTag(stopArea.selectedObject, OSMTags.HIGHWAY_TAG, OSMTags.BUS_STOP_TAG_VALUE) || stopArea.isBusStation)) 155 { 156 stopArea.isBus = true; 157 } 158 } 29 /** 30 * Parsing of josm object tags and customizing of stop area object 31 * 32 * @param member Josm object 33 */ 34 public void parseTags(StopArea stopArea, OsmPrimitive member) { 35 if (stopArea.name == null) 36 stopArea.name = getTagValue(member, OSMTags.NAME_TAG); 37 if (stopArea.nameEn == null) 38 stopArea.nameEn = getTagValue(member, OSMTags.NAME_EN_TAG); 39 if (stopArea.operator == null) 40 stopArea.operator = getTagValue(member, OSMTags.OPERATOR_TAG); 41 if (stopArea.network == null) 42 stopArea.network = getTagValue(member, OSMTags.NETWORK_TAG); 43 if (stopArea.service == null) 44 stopArea.service = getTagValue(member, OSMTags.SERVICE_TAG); 45 if (OSMTags.LOCAL_NETWORK_TAG_VALUE.equals(stopArea.service)) 46 stopArea.service = OSMTags.COMMUTER_NETWORK_TAG_VALUE; 47 if (compareTag(member, OSMTags.BUS_TAG, OSMTags.YES_TAG_VALUE)) 48 stopArea.isBus = true; 49 if (compareTag(member, OSMTags.TROLLEYBUS_TAG, OSMTags.YES_TAG_VALUE)) 50 stopArea.isTrolleybus = true; 51 if (compareTag(member, OSMTags.SHARE_TAXI_TAG, OSMTags.YES_TAG_VALUE)) 52 stopArea.isShareTaxi = true; 53 if (!(stopArea.isBus || stopArea.isShareTaxi || stopArea.isTrolleybus) 54 && compareTag(member, OSMTags.HIGHWAY_TAG, OSMTags.BUS_STOP_TAG_VALUE)) 55 stopArea.isBus = true; 56 if (compareTag(member, OSMTags.TRAM_TAG, OSMTags.YES_TAG_VALUE) 57 || compareTag(member, OSMTags.RAILWAY_TAG, OSMTags.TRAM_STOP_TAG_VALUE)) 58 stopArea.isTram = true; 59 if (compareTag(member, OSMTags.RAILWAY_TAG, OSMTags.HALT_TAG_VALUE)) 60 stopArea.isTrainStop = true; 61 if (compareTag(member, OSMTags.RAILWAY_TAG, OSMTags.STATION_TAG_VALUE)) 62 stopArea.isTrainStation = true; 63 if (compareTag(member, OSMTags.AMENITY_TAG, OSMTags.BUS_STATION_TAG_VALUE)) { 64 stopArea.isBusStation = true; 65 } 66 if (member == stopArea.selectedObject) { 67 if (compareTag(member, OSMTags.BENCH_TAG, OSMTags.YES_TAG_VALUE)) 68 stopArea.isBench = true; 69 if (compareTag(member, OSMTags.SHELTER_TAG, OSMTags.YES_TAG_VALUE)) 70 stopArea.isShelter = true; 71 if (compareTag(member, OSMTags.COVERED_TAG, OSMTags.YES_TAG_VALUE)) 72 stopArea.isCovered = true; 73 if (compareTag(member, OSMTags.AREA_TAG, OSMTags.YES_TAG_VALUE)) 74 stopArea.isArea = true; 75 } 76 } 159 77 160 /** 161 * Construct stop area object from selected JOSM object 162 * @param stopArea Original stop area object 163 * @return Stop area objects with settings of selected JOSM object and included it stop area relation 164 */ 165 @Override 166 public StopArea performCustomizing(StopArea stopArea) 167 { 168 if(getCurrentDataSet() == null) 169 return null; 170 OsmPrimitive selectedObject = getCurrentDataSet().getSelectedNodesAndWays().iterator().next(); 171 if(selectedObject == null) 172 return null; 173 if(stopArea == null) 174 stopArea = new StopArea(selectedObject); 175 fromSelectedObject(stopArea); 176 return stopArea; 177 } 78 /** 79 * Test, are transport types assigned to platforms 80 * 81 * @param platform Platform object 82 * @return true, if transport types assigned to this platforms 83 */ 84 public boolean testIsTransportTypeAssigned(OsmPrimitive platform) { 85 String[] transportTypes = new String[] {OSMTags.BUS_TAG, OSMTags.TROLLEYBUS_TAG, OSMTags.SHARE_TAXI_TAG, 86 OSMTags.TRAM_TAG, OSMTags.TRAIN_TAG}; 87 for (String transportType : transportTypes) { 88 if (compareTag(platform, transportType, OSMTags.YES_TAG_VALUE)) 89 return true; 90 } 91 return false; 92 } 93 94 /** 95 * Setting of stop area from selected josm object 96 * 97 * @param selectedObject Selected josm object 98 */ 99 public void fromSelectedObject(StopArea stopArea) { 100 Collection<OsmPrimitive> selectedObjects = new ArrayList<OsmPrimitive>(); 101 selectedObjects.add(stopArea.selectedObject); 102 for (Relation rel : OsmPrimitive.getParentRelations(selectedObjects)) { 103 if (compareTag(rel, OSMTags.TYPE_TAG, OSMTags.PUBLIC_TRANSPORT_TAG) 104 && compareTag(rel, OSMTags.PUBLIC_TRANSPORT_TAG, OSMTags.STOP_AREA_TAG_VALUE)) { 105 stopArea.stopAreaRelation = rel; 106 } 107 if (stopArea.stopAreaRelation != null) 108 break; 109 } 110 111 if (stopArea.stopAreaRelation != null) { 112 parseTags(stopArea, stopArea.stopAreaRelation); 113 parseTags(stopArea, stopArea.selectedObject); 114 for (RelationMember member : stopArea.stopAreaRelation.getMembers()) { 115 if (member.getMember() instanceof Node && compareTag(member.getMember(), OSMTags.PUBLIC_TRANSPORT_TAG, 116 OSMTags.STOP_POSITION_TAG_VALUE)) { 117 stopArea.isStopPointExists = true; 118 stopArea.stopPoints.add(member.getNode()); 119 } else if (compareTag(member.getMember(), OSMTags.PUBLIC_TRANSPORT_TAG, OSMTags.PLATFORM_TAG_VALUE)) { 120 stopArea.platforms.add(member.getMember()); 121 } else { 122 stopArea.otherMembers.add(member.getMember()); 123 } 124 parseTags(stopArea, member.getMember()); 125 } 126 if (!stopArea.platforms.contains(stopArea.selectedObject)) { 127 parseTags(stopArea, stopArea.selectedObject); 128 stopArea.platforms.add(stopArea.selectedObject); 129 } 130 } else { 131 parseTags(stopArea, stopArea.selectedObject); 132 stopArea.platforms.add(stopArea.selectedObject); 133 } 134 for (OsmPrimitive platform : stopArea.platforms) { 135 if (testIsTransportTypeAssigned(platform)) { 136 stopArea.isAssignTransportType = true; 137 break; 138 } 139 } 140 if (!(stopArea.isBus || stopArea.isTrolleybus || stopArea.isShareTaxi) && stopArea.selectedObject != null 141 && (compareTag(stopArea.selectedObject, OSMTags.HIGHWAY_TAG, OSMTags.BUS_STOP_TAG_VALUE) 142 || stopArea.isBusStation)) { 143 stopArea.isBus = true; 144 } 145 } 146 147 /** 148 * Construct stop area object from selected JOSM object 149 * 150 * @param stopArea Original stop area object 151 * @return Stop area objects with settings of selected JOSM object and included 152 * it stop area relation 153 */ 154 @Override 155 public StopArea performCustomizing(StopArea stopArea) { 156 if (getCurrentDataSet() == null) 157 return null; 158 OsmPrimitive selectedObject = getCurrentDataSet().getSelectedNodesAndWays().iterator().next(); 159 if (selectedObject == null) 160 return null; 161 if (stopArea == null) 162 stopArea = new StopArea(selectedObject); 163 fromSelectedObject(stopArea); 164 return stopArea; 165 } 178 166 179 167 } -
applications/editors/josm/plugins/CustomizePublicTransportStop/src/ru/rodsoft/openstreetmap/josm/plugins/customizepublictransportstop/CustomizePublicTransportStopDialog.java
r32840 r34156 1 // License: GPL. For details, see LICENSE file. 1 2 package ru.rodsoft.openstreetmap.josm.plugins.customizepublictransportstop; 2 3 … … 24 25 import org.openstreetmap.josm.Main; 25 26 26 import ru.rodsoft.openstreetmap.josm.plugins.customizepublictransportstop.MessageBox;27 28 27 /** 28 * Dialog for setting stop area properties 29 29 * 30 30 * @author Rodion Scherbakov 31 * Dialog for setting stop area properties32 31 */ 33 public class CustomizePublicTransportStopDialog implements ActionListener, ItemListener 34 { 35 private static final String CANCEL_COMMAND = "cancel"; 36 private static final String SAVE_COMMAND = "save"; 37 private static final String CANCEL_BUTTON_CAPTION = "Cancel"; 38 private static final String SAVE_BUTTON_CAPTION = "Save"; 39 private static final String AREA_CAPTION = "Area"; 40 private static final String COVER_CAPTION = "Cover"; 41 private static final String SHELDER_CAPTION = "Shelder"; 42 private static final String BENCH_CAPTION = "Bench"; 43 private static final String RAILWAY_STOP_CAPTION = "Railway stop"; 44 private static final String RAILWAY_STATION_CAPTION = "Railway station"; 45 private static final String TRAM_CAPTION = "Tram"; 46 private static final String TROLLEYBUS_CAPTION = "Trolleybus"; 47 private static final String SHARE_TAXI_CAPTION = "Share taxi"; 48 private static final String BUS_CAPTION = "Bus"; 49 private static final String BUS_STATION_CAPTION = "Bus station"; 50 private static final String ASSIGN_TRANSPORT_TYPE_CAPTION = "Assign transport type to platform"; 51 private static final String NETWORK_LEVEL_CAPTION = "Network level"; 52 private static final String OPERATOR_CAPTION = "Operator"; 53 private static final String NETWORK_CAPTION = "Network"; 54 private static final String NAME_EN_CAPTION = "Name (en.)"; 55 private static final String NAME_CAPTION = "Name"; 56 private static final String STOP_CUSTOMIZING_DIALOG_CAPTION = "Stop customizing"; 57 public static final String LONG_DISTANCE_NETWORK_CAPTION = "Long distance"; 58 public static final String REGIONAL_NETWORK_CAPTION = "Regional"; 59 public static final String COMMUTER_NETWORK_CAPTION = "Commuter"; 60 public static final String CITY_NETWORK_CAPTION = "City transport"; 61 public static final String HIGH_SPEED_NETWORK_CAPTION = "High speed"; 62 63 private String[] serviceCaptionStrings = { CITY_NETWORK_CAPTION, COMMUTER_NETWORK_CAPTION, REGIONAL_NETWORK_CAPTION, LONG_DISTANCE_NETWORK_CAPTION, HIGH_SPEED_NETWORK_CAPTION }; 64 private String[] serviceStrings = { OSMTags.CITY_NETWORK_TAG_VALUE, OSMTags.COMMUTER_NETWORK_TAG_VALUE, 65 OSMTags.REGIONAL_NETWORK_TAG_VALUE, OSMTags.LONG_DISTANCE_NETWORK_TAG_VALUE, OSMTags.HIGH_SPEED_NETWORK_TAG_VALUE }; 32 public class CustomizePublicTransportStopDialog implements ActionListener, ItemListener { 33 private static final String CANCEL_COMMAND = "cancel"; 34 private static final String SAVE_COMMAND = "save"; 35 private static final String CANCEL_BUTTON_CAPTION = "Cancel"; 36 private static final String SAVE_BUTTON_CAPTION = "Save"; 37 private static final String AREA_CAPTION = "Area"; 38 private static final String COVER_CAPTION = "Cover"; 39 private static final String SHELDER_CAPTION = "Shelder"; 40 private static final String BENCH_CAPTION = "Bench"; 41 private static final String RAILWAY_STOP_CAPTION = "Railway stop"; 42 private static final String RAILWAY_STATION_CAPTION = "Railway station"; 43 private static final String TRAM_CAPTION = "Tram"; 44 private static final String TROLLEYBUS_CAPTION = "Trolleybus"; 45 private static final String SHARE_TAXI_CAPTION = "Share taxi"; 46 private static final String BUS_CAPTION = "Bus"; 47 private static final String BUS_STATION_CAPTION = "Bus station"; 48 private static final String ASSIGN_TRANSPORT_TYPE_CAPTION = "Assign transport type to platform"; 49 private static final String NETWORK_LEVEL_CAPTION = "Network level"; 50 private static final String OPERATOR_CAPTION = "Operator"; 51 private static final String NETWORK_CAPTION = "Network"; 52 private static final String NAME_EN_CAPTION = "Name (en.)"; 53 private static final String NAME_CAPTION = "Name"; 54 private static final String STOP_CUSTOMIZING_DIALOG_CAPTION = "Stop customizing"; 55 public static final String LONG_DISTANCE_NETWORK_CAPTION = "Long distance"; 56 public static final String REGIONAL_NETWORK_CAPTION = "Regional"; 57 public static final String COMMUTER_NETWORK_CAPTION = "Commuter"; 58 public static final String CITY_NETWORK_CAPTION = "City transport"; 59 public static final String HIGH_SPEED_NETWORK_CAPTION = "High speed"; 60 61 private String[] serviceCaptionStrings = {CITY_NETWORK_CAPTION, COMMUTER_NETWORK_CAPTION, REGIONAL_NETWORK_CAPTION, 62 LONG_DISTANCE_NETWORK_CAPTION, HIGH_SPEED_NETWORK_CAPTION}; 63 private String[] serviceStrings = {OSMTags.CITY_NETWORK_TAG_VALUE, OSMTags.COMMUTER_NETWORK_TAG_VALUE, 64 OSMTags.REGIONAL_NETWORK_TAG_VALUE, OSMTags.LONG_DISTANCE_NETWORK_TAG_VALUE, 65 OSMTags.HIGH_SPEED_NETWORK_TAG_VALUE}; 66 66 67 67 private JDialog jDialog = null; 68 private JTextField textFieldName = null; 69 private JTextField textFieldNameEn; 70 private JTextField textFieldNetwork; 71 private JTextField textFieldOperator; 72 private JComboBox<String> comboBoxService; 73 private JCheckBox checkBoxIsBus; 74 private JCheckBox checkBoxIsTrolleybus; 75 private JCheckBox checkBoxIsShareTaxi; 76 private JCheckBox checkBoxIsBusStation; 77 private JCheckBox checkBoxIsAssignTransportType; 78 private JCheckBox checkBoxIsTram; 79 private JCheckBox checkBoxIsTrainStation; 80 private JCheckBox checkBoxIsTrainStop; 81 private JCheckBox checkBoxIsBench; 82 private JCheckBox checkBoxIsShelder; 83 private JCheckBox checkBoxIsCover; 84 private JCheckBox checkBoxIsArea; 85 86 /** 87 * Stop area 88 */ 89 private StopArea stopArea; 90 /** 91 * Customize stop action object for callback 92 */ 93 private CustomizeStopAction customizeStopAction; 94 95 /** 96 * Map of check boxes 97 */ 98 private HashMap<JCheckBox, Boolean> checkBoxValues = new HashMap<JCheckBox,Boolean>(); 99 100 /** 101 * Previous stop name 102 */ 103 private static String previousName; 104 /** 105 * Previous english stop name 106 */ 107 private static String previousNameEn; 108 /** 109 * Network name at previous call 110 */ 111 private static String previousNetwork = null; 112 /** 113 * Operator name at previous call 114 */ 115 private static String previousOperator = null; 116 117 /** 118 * Reference to dialog object 119 */ 120 private static CustomizePublicTransportStopDialog customizePublicTransportStopDialogInstance; 121 122 /** 123 * Construct dialog and fill controls 124 * @param customizeStopAction Stop area customizing action 125 * @param stopArea Stop area 126 * @return Reference to dialog 127 */ 128 public static CustomizePublicTransportStopDialog showCustomizePublicTransportStopDialog(CustomizeStopAction customizeStopAction, StopArea stopArea) 129 { 130 if(customizePublicTransportStopDialogInstance == null) 131 { 132 customizePublicTransportStopDialogInstance = new CustomizePublicTransportStopDialog(customizeStopAction, stopArea); 133 } 134 else 135 { 136 customizePublicTransportStopDialogInstance.setCustomizeStopAction(customizeStopAction); 137 customizePublicTransportStopDialogInstance.setStopArea(stopArea); 138 } 139 customizePublicTransportStopDialogInstance.setVisible(true); 140 return customizePublicTransportStopDialogInstance; 141 } 142 143 /** 144 * Constructor of dialog 145 */ 146 public CustomizePublicTransportStopDialog() 147 { 148 Frame frame = JOptionPane.getFrameForComponent(Main.parent); 149 jDialog = new JDialog(frame, tr(STOP_CUSTOMIZING_DIALOG_CAPTION), false); 150 JPanel contentPane = new JPanel(); 151 GridBagLayout gridbag = new GridBagLayout(); 152 contentPane.setLayout(gridbag); 153 GridBagConstraints layoutCons = new GridBagConstraints(); 154 JLabel label = new JLabel(tr(NAME_CAPTION)); 155 layoutCons.gridx = 0; 156 layoutCons.gridy = 0; 157 layoutCons.weightx = 0.5; 158 layoutCons.fill = GridBagConstraints.HORIZONTAL; 159 gridbag.setConstraints(label, layoutCons); 160 contentPane.add(label); 161 162 textFieldName = new JTextField("", 25); 163 layoutCons.gridx = 1; 164 layoutCons.gridy = 0; 165 layoutCons.weightx = 0.5; 166 layoutCons.fill = GridBagConstraints.HORIZONTAL; 167 gridbag.setConstraints(textFieldName, layoutCons); 168 contentPane.add(textFieldName); 169 170 JLabel labelNameEn = new JLabel(tr(NAME_EN_CAPTION)); 171 layoutCons.gridx = 0; 172 layoutCons.gridy = 1; 173 layoutCons.weightx = 0.5; 174 layoutCons.fill = GridBagConstraints.HORIZONTAL; 175 gridbag.setConstraints(labelNameEn, layoutCons); 176 contentPane.add(labelNameEn); 177 178 textFieldNameEn = new JTextField("", 25); 179 layoutCons.gridx = 1; 180 layoutCons.gridy = 1; 181 layoutCons.weightx = 0.5; 182 layoutCons.fill = GridBagConstraints.HORIZONTAL; 183 gridbag.setConstraints(textFieldNameEn, layoutCons); 184 contentPane.add(textFieldNameEn); 185 186 JLabel labelNetwork = new JLabel(tr(NETWORK_CAPTION)); 187 layoutCons.gridx = 0; 188 layoutCons.gridy = 2; 189 layoutCons.weightx = 0.5; 190 layoutCons.fill = GridBagConstraints.HORIZONTAL; 191 gridbag.setConstraints(labelNetwork, layoutCons); 192 contentPane.add(labelNetwork); 193 194 textFieldNetwork = new JTextField("", 25); 195 layoutCons.gridx = 1; 196 layoutCons.gridy = 2; 197 layoutCons.weightx = 0.5; 198 layoutCons.fill = GridBagConstraints.HORIZONTAL; 199 gridbag.setConstraints(textFieldNetwork, layoutCons); 200 contentPane.add(textFieldNetwork); 201 202 JLabel labelOperator = new JLabel(tr(OPERATOR_CAPTION)); 203 layoutCons.gridx = 0; 204 layoutCons.gridy = 3; 205 layoutCons.weightx = 0.5; 206 layoutCons.fill = GridBagConstraints.HORIZONTAL; 207 gridbag.setConstraints(labelOperator, layoutCons); 208 contentPane.add(labelOperator); 209 210 textFieldOperator = new JTextField("", 25); 211 layoutCons.gridx = 1; 212 layoutCons.gridy = 3; 213 layoutCons.weightx = 0.5; 214 layoutCons.fill = GridBagConstraints.HORIZONTAL; 215 gridbag.setConstraints(textFieldOperator, layoutCons); 216 contentPane.add(textFieldOperator); 217 218 JLabel labelService = new JLabel(tr(NETWORK_LEVEL_CAPTION)); 219 layoutCons.gridx = 0; 220 layoutCons.gridy = 4; 221 layoutCons.weightx = 0.5; 222 layoutCons.fill = GridBagConstraints.HORIZONTAL; 223 gridbag.setConstraints(labelService, layoutCons); 224 contentPane.add(labelService); 225 226 String[] serviceTransStrings = new String[serviceCaptionStrings.length]; 227 for(int i = 0; i < serviceCaptionStrings.length; i++) 228 serviceTransStrings[i] = tr(serviceCaptionStrings[i]); 229 comboBoxService = new JComboBox<String>(serviceTransStrings); 230 comboBoxService.setSelectedIndex(0); 231 layoutCons.gridx = 1; 232 layoutCons.gridy = 4; 233 layoutCons.weightx = 0.5; 234 layoutCons.fill = GridBagConstraints.HORIZONTAL; 235 gridbag.setConstraints(comboBoxService, layoutCons); 68 private JTextField textFieldName = null; 69 private JTextField textFieldNameEn; 70 private JTextField textFieldNetwork; 71 private JTextField textFieldOperator; 72 private JComboBox<String> comboBoxService; 73 private JCheckBox checkBoxIsBus; 74 private JCheckBox checkBoxIsTrolleybus; 75 private JCheckBox checkBoxIsShareTaxi; 76 private JCheckBox checkBoxIsBusStation; 77 private JCheckBox checkBoxIsAssignTransportType; 78 private JCheckBox checkBoxIsTram; 79 private JCheckBox checkBoxIsTrainStation; 80 private JCheckBox checkBoxIsTrainStop; 81 private JCheckBox checkBoxIsBench; 82 private JCheckBox checkBoxIsShelder; 83 private JCheckBox checkBoxIsCover; 84 private JCheckBox checkBoxIsArea; 85 86 /** 87 * Stop area 88 */ 89 private StopArea stopArea; 90 /** 91 * Customize stop action object for callback 92 */ 93 private CustomizeStopAction customizeStopAction; 94 95 /** 96 * Map of check boxes 97 */ 98 private HashMap<JCheckBox, Boolean> checkBoxValues = new HashMap<JCheckBox, Boolean>(); 99 100 /** 101 * Previous stop name 102 */ 103 private static String previousName; 104 /** 105 * Previous english stop name 106 */ 107 private static String previousNameEn; 108 /** 109 * Network name at previous call 110 */ 111 private static String previousNetwork = null; 112 /** 113 * Operator name at previous call 114 */ 115 private static String previousOperator = null; 116 117 /** 118 * Reference to dialog object 119 */ 120 private static CustomizePublicTransportStopDialog customizePublicTransportStopDialogInstance; 121 122 /** 123 * Construct dialog and fill controls 124 * 125 * @param customizeStopAction Stop area customizing action 126 * @param stopArea Stop area 127 * @return Reference to dialog 128 */ 129 public static CustomizePublicTransportStopDialog showCustomizePublicTransportStopDialog( 130 CustomizeStopAction customizeStopAction, StopArea stopArea) { 131 if (customizePublicTransportStopDialogInstance == null) { 132 customizePublicTransportStopDialogInstance = new CustomizePublicTransportStopDialog(customizeStopAction, 133 stopArea); 134 } else { 135 customizePublicTransportStopDialogInstance.setCustomizeStopAction(customizeStopAction); 136 customizePublicTransportStopDialogInstance.setStopArea(stopArea); 137 } 138 customizePublicTransportStopDialogInstance.setVisible(true); 139 return customizePublicTransportStopDialogInstance; 140 } 141 142 /** 143 * Constructor of dialog 144 */ 145 public CustomizePublicTransportStopDialog() { 146 Frame frame = JOptionPane.getFrameForComponent(Main.parent); 147 jDialog = new JDialog(frame, tr(STOP_CUSTOMIZING_DIALOG_CAPTION), false); 148 JPanel contentPane = createContentPane(); 149 150 jDialog.add(contentPane); 151 152 jDialog.pack(); 153 jDialog.setLocationRelativeTo(frame); 154 } 155 156 private JPanel createContentPane() { 157 JPanel contentPane = new JPanel(); 158 GridBagLayout gridbag = new GridBagLayout(); 159 contentPane.setLayout(gridbag); 160 GridBagConstraints layoutCons = new GridBagConstraints(); 161 JLabel label = new JLabel(tr(NAME_CAPTION)); 162 layoutCons.gridx = 0; 163 layoutCons.gridy = 0; 164 layoutCons.weightx = 0.5; 165 layoutCons.fill = GridBagConstraints.HORIZONTAL; 166 gridbag.setConstraints(label, layoutCons); 167 contentPane.add(label); 168 169 textFieldName = new JTextField("", 25); 170 layoutCons.gridx = 1; 171 layoutCons.gridy = 0; 172 layoutCons.weightx = 0.5; 173 layoutCons.fill = GridBagConstraints.HORIZONTAL; 174 gridbag.setConstraints(textFieldName, layoutCons); 175 contentPane.add(textFieldName); 176 177 JLabel labelNameEn = new JLabel(tr(NAME_EN_CAPTION)); 178 layoutCons.gridx = 0; 179 layoutCons.gridy = 1; 180 layoutCons.weightx = 0.5; 181 layoutCons.fill = GridBagConstraints.HORIZONTAL; 182 gridbag.setConstraints(labelNameEn, layoutCons); 183 contentPane.add(labelNameEn); 184 185 textFieldNameEn = new JTextField("", 25); 186 layoutCons.gridx = 1; 187 layoutCons.gridy = 1; 188 layoutCons.weightx = 0.5; 189 layoutCons.fill = GridBagConstraints.HORIZONTAL; 190 gridbag.setConstraints(textFieldNameEn, layoutCons); 191 contentPane.add(textFieldNameEn); 192 193 JLabel labelNetwork = new JLabel(tr(NETWORK_CAPTION)); 194 layoutCons.gridx = 0; 195 layoutCons.gridy = 2; 196 layoutCons.weightx = 0.5; 197 layoutCons.fill = GridBagConstraints.HORIZONTAL; 198 gridbag.setConstraints(labelNetwork, layoutCons); 199 contentPane.add(labelNetwork); 200 201 textFieldNetwork = new JTextField("", 25); 202 layoutCons.gridx = 1; 203 layoutCons.gridy = 2; 204 layoutCons.weightx = 0.5; 205 layoutCons.fill = GridBagConstraints.HORIZONTAL; 206 gridbag.setConstraints(textFieldNetwork, layoutCons); 207 contentPane.add(textFieldNetwork); 208 209 JLabel labelOperator = new JLabel(tr(OPERATOR_CAPTION)); 210 layoutCons.gridx = 0; 211 layoutCons.gridy = 3; 212 layoutCons.weightx = 0.5; 213 layoutCons.fill = GridBagConstraints.HORIZONTAL; 214 gridbag.setConstraints(labelOperator, layoutCons); 215 contentPane.add(labelOperator); 216 217 textFieldOperator = new JTextField("", 25); 218 layoutCons.gridx = 1; 219 layoutCons.gridy = 3; 220 layoutCons.weightx = 0.5; 221 layoutCons.fill = GridBagConstraints.HORIZONTAL; 222 gridbag.setConstraints(textFieldOperator, layoutCons); 223 contentPane.add(textFieldOperator); 224 225 JLabel labelService = new JLabel(tr(NETWORK_LEVEL_CAPTION)); 226 layoutCons.gridx = 0; 227 layoutCons.gridy = 4; 228 layoutCons.weightx = 0.5; 229 layoutCons.fill = GridBagConstraints.HORIZONTAL; 230 gridbag.setConstraints(labelService, layoutCons); 231 contentPane.add(labelService); 232 233 String[] serviceTransStrings = new String[serviceCaptionStrings.length]; 234 for (int i = 0; i < serviceCaptionStrings.length; i++) { 235 serviceTransStrings[i] = tr(serviceCaptionStrings[i]); 236 } 237 comboBoxService = new JComboBox<String>(serviceTransStrings); 238 comboBoxService.setSelectedIndex(0); 239 layoutCons.gridx = 1; 240 layoutCons.gridy = 4; 241 layoutCons.weightx = 0.5; 242 layoutCons.fill = GridBagConstraints.HORIZONTAL; 243 gridbag.setConstraints(comboBoxService, layoutCons); 236 244 contentPane.add(comboBoxService); 237 238 checkBoxIsBus = new JCheckBox(tr(BUS_CAPTION)); 239 layoutCons.gridx = 0; 240 layoutCons.gridy = 5; 241 layoutCons.weightx = 0.5; 242 layoutCons.fill = GridBagConstraints.HORIZONTAL; 243 gridbag.setConstraints(checkBoxIsBus, layoutCons); 244 checkBoxIsBus.addItemListener(this); 245 contentPane.add(checkBoxIsBus); 246 247 checkBoxIsShareTaxi = new JCheckBox(tr(SHARE_TAXI_CAPTION)); 248 layoutCons.gridx = 1; 249 layoutCons.gridy = 5; 250 layoutCons.weightx = 0.5; 251 layoutCons.fill = GridBagConstraints.HORIZONTAL; 252 gridbag.setConstraints(checkBoxIsShareTaxi, layoutCons); 253 checkBoxIsShareTaxi.addItemListener(this); 254 contentPane.add(checkBoxIsShareTaxi); 255 256 checkBoxIsTrolleybus = new JCheckBox(tr(TROLLEYBUS_CAPTION)); 257 layoutCons.gridx = 0; 258 layoutCons.gridy = 6; 259 layoutCons.weightx = 0.5; 260 layoutCons.fill = GridBagConstraints.HORIZONTAL; 261 gridbag.setConstraints(checkBoxIsTrolleybus, layoutCons); 262 checkBoxIsTrolleybus.addItemListener(this); 263 contentPane.add(checkBoxIsTrolleybus); 264 265 checkBoxIsBusStation = new JCheckBox(tr(BUS_STATION_CAPTION)); 266 layoutCons.gridx = 1; 267 layoutCons.gridy = 6; 268 layoutCons.weightx = 0.5; 269 layoutCons.fill = GridBagConstraints.HORIZONTAL; 270 gridbag.setConstraints(checkBoxIsBusStation, layoutCons); 271 checkBoxIsBusStation.addItemListener(this); 272 contentPane.add(checkBoxIsBusStation); 273 274 checkBoxIsTram = new JCheckBox(tr(TRAM_CAPTION)); 275 layoutCons.gridx = 0; 276 layoutCons.gridy = 7; 277 layoutCons.weightx = 0.5; 278 layoutCons.fill = GridBagConstraints.HORIZONTAL; 279 gridbag.setConstraints(checkBoxIsTram, layoutCons); 280 checkBoxIsTram.addItemListener(this); 281 contentPane.add(checkBoxIsTram); 282 283 checkBoxIsTrainStation = new JCheckBox(tr(RAILWAY_STATION_CAPTION)); 284 layoutCons.gridx = 0; 285 layoutCons.gridy = 8; 286 layoutCons.weightx = 0.5; 287 layoutCons.fill = GridBagConstraints.HORIZONTAL; 288 gridbag.setConstraints(checkBoxIsTrainStation, layoutCons); 289 checkBoxIsTrainStation.addItemListener(this); 290 contentPane.add(checkBoxIsTrainStation); 291 292 checkBoxIsTrainStop = new JCheckBox(tr(RAILWAY_STOP_CAPTION)); 293 layoutCons.gridx = 1; 294 layoutCons.gridy = 8; 295 layoutCons.weightx = 0.5; 296 layoutCons.fill = GridBagConstraints.HORIZONTAL; 297 gridbag.setConstraints(checkBoxIsTrainStop, layoutCons); 298 checkBoxIsTrainStop.addItemListener(this); 299 contentPane.add(checkBoxIsTrainStop); 300 301 checkBoxIsAssignTransportType = new JCheckBox(tr(ASSIGN_TRANSPORT_TYPE_CAPTION)); 302 layoutCons.gridx = 0; 303 layoutCons.gridy = 9; 304 layoutCons.weightx = 0.5; 305 layoutCons.fill = GridBagConstraints.HORIZONTAL; 306 gridbag.setConstraints(checkBoxIsAssignTransportType, layoutCons); 307 checkBoxIsAssignTransportType.addItemListener(this); 308 contentPane.add(checkBoxIsAssignTransportType); 309 310 checkBoxIsBench = new JCheckBox(tr(BENCH_CAPTION)); 311 layoutCons.gridx = 0; 312 layoutCons.gridy = 10; 313 layoutCons.weightx = 0.5; 314 layoutCons.fill = GridBagConstraints.HORIZONTAL; 315 gridbag.setConstraints(checkBoxIsBench, layoutCons); 316 checkBoxIsBench.addItemListener(this); 317 contentPane.add(checkBoxIsBench); 318 319 checkBoxIsShelder = new JCheckBox(tr(SHELDER_CAPTION)); 320 layoutCons.gridx = 1; 321 layoutCons.gridy = 10; 322 layoutCons.weightx = 0.5; 323 layoutCons.fill = GridBagConstraints.HORIZONTAL; 324 gridbag.setConstraints(checkBoxIsShelder, layoutCons); 325 checkBoxIsShelder.addItemListener(this); 326 contentPane.add(checkBoxIsShelder); 327 328 checkBoxIsCover = new JCheckBox(tr(COVER_CAPTION)); 329 layoutCons.gridx = 0; 330 layoutCons.gridy = 11; 331 layoutCons.weightx = 0.5; 332 layoutCons.fill = GridBagConstraints.HORIZONTAL; 333 gridbag.setConstraints(checkBoxIsCover, layoutCons); 334 checkBoxIsCover.addItemListener(this); 335 contentPane.add(checkBoxIsCover); 336 337 checkBoxIsArea = new JCheckBox(tr(AREA_CAPTION)); 338 layoutCons.gridx = 1; 339 layoutCons.gridy = 11; 340 layoutCons.weightx = 0.5; 341 layoutCons.fill = GridBagConstraints.HORIZONTAL; 342 gridbag.setConstraints(checkBoxIsArea, layoutCons); 343 checkBoxIsArea.addItemListener(this); 344 contentPane.add(checkBoxIsArea); 345 346 JButton buttonSave = new JButton(tr(SAVE_BUTTON_CAPTION)); 347 layoutCons.gridx = 0; 348 layoutCons.gridy = 12; 349 layoutCons.weightx = 0.5; 350 layoutCons.fill = GridBagConstraints.HORIZONTAL; 351 layoutCons.insets = new Insets(10, 0 , 0, 0); 352 gridbag.setConstraints(buttonSave, layoutCons); 353 buttonSave.setActionCommand(SAVE_COMMAND); 354 buttonSave.addActionListener(this); 355 contentPane.add(buttonSave); 356 357 JButton buttonCancel = new JButton(tr(CANCEL_BUTTON_CAPTION)); 358 layoutCons.gridx = 1; 359 layoutCons.gridy = 12; 360 layoutCons.weightx = 0.5; 361 layoutCons.fill = GridBagConstraints.LINE_START; 362 layoutCons.insets = new Insets(10, 0 , 0, 0); 363 gridbag.setConstraints(buttonCancel, layoutCons); 364 buttonCancel.setActionCommand(CANCEL_COMMAND); 365 buttonCancel.addActionListener(this); 366 contentPane.add(buttonCancel); 367 368 jDialog.add(contentPane); 369 370 jDialog.pack(); 371 jDialog.setLocationRelativeTo(frame); 372 } 373 374 /** 375 * Constructor of dialog with filling of controls 376 * @param customizeStopAction Stop area customizing action 377 * @param stopArea Stop area 378 */ 379 public CustomizePublicTransportStopDialog(CustomizeStopAction customizeStopAction, StopArea stopArea) 380 { 381 this(); 382 setValues(stopArea); 383 this.customizeStopAction = customizeStopAction; 384 this.stopArea = stopArea; 385 } 386 387 /** 388 * Return stop area 389 * @return Stop area 390 */ 391 public StopArea getStopArea() 392 { 393 return stopArea; 394 } 395 396 /** 397 * Set stop area and fill controls 398 * @param newStopArea Stop area 399 */ 400 public void setStopArea(StopArea newStopArea) 401 { 402 setValues(newStopArea); 403 this.stopArea = newStopArea; 404 } 405 406 /** 407 * Returns stop area customizing action 408 * @return Stop area customizing action 409 */ 410 public CustomizeStopAction getCustomizeStopAction() 411 { 412 return customizeStopAction; 413 } 414 415 /** 416 * Set stop area customizing action 417 * @param newCustomizeStopAction Stop area customizing action 418 */ 419 public void setCustomizeStopAction(CustomizeStopAction newCustomizeStopAction) 420 { 421 customizeStopAction = newCustomizeStopAction; 422 } 423 424 /** 425 * Set value in check boxes map 426 * @param checkBox Check box 427 * @param value Value of check box 428 */ 429 public void setCheckBoxValue(JCheckBox checkBox, Boolean value) 430 { 431 checkBoxValues.put(checkBox, value); 432 checkBox.setSelected(value); 433 } 434 435 /** 436 * Returns value of check box 437 * @param checkBox Check box 438 * @return Value of check box 439 */ 440 public Boolean getCheckBoxValue(JCheckBox checkBox) 441 { 442 try 443 { 444 if(checkBoxValues.containsKey(checkBox)) 445 { 446 return checkBoxValues.get(checkBox); 447 } 448 return false; 449 } 450 catch(Exception ex) 451 { 452 MessageBox.ok(ex.getMessage()); 453 } 454 return false; 455 } 456 457 /** 458 * Callback method for check boxes 459 * Set values in check boxes map 460 */ 461 @Override 462 public void itemStateChanged(ItemEvent event) 463 { 464 JCheckBox checkBox = (JCheckBox)event.getSource(); 465 if(event.getStateChange() == ItemEvent.DESELECTED) 466 { 467 checkBoxValues.put(checkBox, false); 468 } 469 else 470 if(event.getStateChange() == ItemEvent.SELECTED) 471 { 472 checkBoxValues.put(checkBox, true); 473 } 474 } 475 476 /** 477 * Show or hide dialog 478 * @param isVisible Flag of dialog visibility 479 */ 480 public void setVisible(Boolean isVisible) 481 { 482 if(jDialog != null) 483 jDialog.setVisible(isVisible); 484 } 485 486 /** 487 * Get index of network level 488 * @param service Network level name 489 * @return Index of network level 490 */ 491 private int getServiceIndex(String service) 492 { 493 for(int i = 0; i < serviceStrings.length; i++) 494 { 495 if(serviceStrings[i].equals(service)) 496 { 497 return i; 498 } 499 } 500 return 0; 501 } 502 503 /** 504 * Setting values of controls from stop area 505 * @param stopArea Stop area 506 */ 507 public void setValues(StopArea stopArea) 508 { 509 if(stopArea == null) 510 return; 511 if(stopArea.name != null) 512 textFieldName.setText(stopArea.name); 513 else 514 if(previousName != null) 515 textFieldName.setText(previousName); 516 if(stopArea.nameEn != null) 517 textFieldNameEn.setText(stopArea.nameEn); 518 else 519 if(previousNameEn != null) 520 textFieldNameEn.setText(previousNameEn); 521 if(stopArea.network != null) 522 textFieldNetwork.setText(stopArea.network); 523 else 524 if(previousNetwork != null) 525 textFieldNetwork.setText(previousNetwork); 526 if(stopArea.operator != null) 527 textFieldOperator.setText(stopArea.operator); 528 else 529 if(previousOperator != null) 530 textFieldOperator.setText(previousOperator); 531 comboBoxService.setSelectedIndex(getServiceIndex(stopArea.service)); 532 setCheckBoxValue(checkBoxIsBus, stopArea.isBus); 533 setCheckBoxValue(checkBoxIsShareTaxi, stopArea.isShareTaxi); 534 setCheckBoxValue(checkBoxIsTrolleybus, stopArea.isTrolleybus); 535 setCheckBoxValue(checkBoxIsBusStation, stopArea.isBusStation); 536 setCheckBoxValue(checkBoxIsAssignTransportType, stopArea.isAssignTransportType); 537 setCheckBoxValue(checkBoxIsTram, stopArea.isTram); 538 setCheckBoxValue(checkBoxIsTrainStation, stopArea.isTrainStation); 539 setCheckBoxValue(checkBoxIsTrainStop, stopArea.isTrainStation); 540 setCheckBoxValue(checkBoxIsTrainStop, stopArea.isTrainStop); 541 setCheckBoxValue(checkBoxIsBench, stopArea.isBench); 542 setCheckBoxValue(checkBoxIsShelder, stopArea.isShelter); 543 setCheckBoxValue(checkBoxIsCover, stopArea.isCovered); 544 setCheckBoxValue(checkBoxIsArea, stopArea.isArea); 545 } 546 547 /** 548 * Returns text box value or null 549 * @param textField Text box 550 * @return Text box value or null 551 */ 552 public String getTextFromControl(JTextField textField) 553 { 554 if(textField.getText().isEmpty()) 555 return null; 556 return textField.getText(); 557 } 558 559 /** 560 * Load values from controls and saving in stop area fields 561 * @return Stop area 562 */ 563 public StopArea saveValues() 564 { 565 StopArea stopArea = this.stopArea; 566 try 567 { 568 if(stopArea == null) 569 stopArea = new StopArea(); 570 stopArea.name = getTextFromControl(textFieldName); 571 previousName = stopArea.name; 572 stopArea.nameEn = getTextFromControl(textFieldNameEn); 573 previousNameEn = stopArea.nameEn; 574 stopArea.network = getTextFromControl(textFieldNetwork); 575 previousNetwork = stopArea.network; 576 stopArea.operator = getTextFromControl(textFieldOperator); 577 previousOperator = stopArea.operator; 578 stopArea.service = serviceStrings[comboBoxService.getSelectedIndex()]; 579 stopArea.isBus = getCheckBoxValue(checkBoxIsBus); 580 stopArea.isShareTaxi = getCheckBoxValue(checkBoxIsShareTaxi); 581 stopArea.isTrolleybus = getCheckBoxValue(checkBoxIsTrolleybus); 582 stopArea.isBusStation = getCheckBoxValue(checkBoxIsBusStation); 583 stopArea.isAssignTransportType = getCheckBoxValue(checkBoxIsAssignTransportType); 584 stopArea.isTram = getCheckBoxValue(checkBoxIsTram); 585 stopArea.isTrainStation = getCheckBoxValue(checkBoxIsTrainStation); 586 stopArea.isTrainStop = getCheckBoxValue(checkBoxIsTrainStop); 587 stopArea.isBench = getCheckBoxValue(checkBoxIsBench); 588 stopArea.isShelter = getCheckBoxValue(checkBoxIsShelder); 589 stopArea.isCovered = getCheckBoxValue(checkBoxIsCover); 590 stopArea.isArea = getCheckBoxValue(checkBoxIsArea); 591 } 592 catch(Exception ex) 593 { 594 MessageBox.ok(ex.getMessage()); 595 } 596 return stopArea; 597 } 598 599 /** 600 * Callback method for buttons event 601 */ 602 public void actionPerformed(ActionEvent event) 603 { 604 if(SAVE_COMMAND.equals(event.getActionCommand())) 605 { 606 setVisible(false); 607 if(customizeStopAction != null) 608 { 609 StopArea stopArea = saveValues(); 610 customizeStopAction.performCustomizing(stopArea); 611 } 612 } 613 else 614 { 615 setVisible(false); 616 } 617 } 245 246 checkBoxIsBus = new JCheckBox(tr(BUS_CAPTION)); 247 layoutCons.gridx = 0; 248 layoutCons.gridy = 5; 249 layoutCons.weightx = 0.5; 250 layoutCons.fill = GridBagConstraints.HORIZONTAL; 251 gridbag.setConstraints(checkBoxIsBus, layoutCons); 252 checkBoxIsBus.addItemListener(this); 253 contentPane.add(checkBoxIsBus); 254 255 checkBoxIsShareTaxi = new JCheckBox(tr(SHARE_TAXI_CAPTION)); 256 layoutCons.gridx = 1; 257 layoutCons.gridy = 5; 258 layoutCons.weightx = 0.5; 259 layoutCons.fill = GridBagConstraints.HORIZONTAL; 260 gridbag.setConstraints(checkBoxIsShareTaxi, layoutCons); 261 checkBoxIsShareTaxi.addItemListener(this); 262 contentPane.add(checkBoxIsShareTaxi); 263 264 checkBoxIsTrolleybus = new JCheckBox(tr(TROLLEYBUS_CAPTION)); 265 layoutCons.gridx = 0; 266 layoutCons.gridy = 6; 267 layoutCons.weightx = 0.5; 268 layoutCons.fill = GridBagConstraints.HORIZONTAL; 269 gridbag.setConstraints(checkBoxIsTrolleybus, layoutCons); 270 checkBoxIsTrolleybus.addItemListener(this); 271 contentPane.add(checkBoxIsTrolleybus); 272 273 checkBoxIsBusStation = new JCheckBox(tr(BUS_STATION_CAPTION)); 274 layoutCons.gridx = 1; 275 layoutCons.gridy = 6; 276 layoutCons.weightx = 0.5; 277 layoutCons.fill = GridBagConstraints.HORIZONTAL; 278 gridbag.setConstraints(checkBoxIsBusStation, layoutCons); 279 checkBoxIsBusStation.addItemListener(this); 280 contentPane.add(checkBoxIsBusStation); 281 282 checkBoxIsTram = new JCheckBox(tr(TRAM_CAPTION)); 283 layoutCons.gridx = 0; 284 layoutCons.gridy = 7; 285 layoutCons.weightx = 0.5; 286 layoutCons.fill = GridBagConstraints.HORIZONTAL; 287 gridbag.setConstraints(checkBoxIsTram, layoutCons); 288 checkBoxIsTram.addItemListener(this); 289 contentPane.add(checkBoxIsTram); 290 291 checkBoxIsTrainStation = new JCheckBox(tr(RAILWAY_STATION_CAPTION)); 292 layoutCons.gridx = 0; 293 layoutCons.gridy = 8; 294 layoutCons.weightx = 0.5; 295 layoutCons.fill = GridBagConstraints.HORIZONTAL; 296 gridbag.setConstraints(checkBoxIsTrainStation, layoutCons); 297 checkBoxIsTrainStation.addItemListener(this); 298 contentPane.add(checkBoxIsTrainStation); 299 300 checkBoxIsTrainStop = new JCheckBox(tr(RAILWAY_STOP_CAPTION)); 301 layoutCons.gridx = 1; 302 layoutCons.gridy = 8; 303 layoutCons.weightx = 0.5; 304 layoutCons.fill = GridBagConstraints.HORIZONTAL; 305 gridbag.setConstraints(checkBoxIsTrainStop, layoutCons); 306 checkBoxIsTrainStop.addItemListener(this); 307 contentPane.add(checkBoxIsTrainStop); 308 309 checkBoxIsAssignTransportType = new JCheckBox(tr(ASSIGN_TRANSPORT_TYPE_CAPTION)); 310 layoutCons.gridx = 0; 311 layoutCons.gridy = 9; 312 layoutCons.weightx = 0.5; 313 layoutCons.fill = GridBagConstraints.HORIZONTAL; 314 gridbag.setConstraints(checkBoxIsAssignTransportType, layoutCons); 315 checkBoxIsAssignTransportType.addItemListener(this); 316 contentPane.add(checkBoxIsAssignTransportType); 317 318 checkBoxIsBench = new JCheckBox(tr(BENCH_CAPTION)); 319 layoutCons.gridx = 0; 320 layoutCons.gridy = 10; 321 layoutCons.weightx = 0.5; 322 layoutCons.fill = GridBagConstraints.HORIZONTAL; 323 gridbag.setConstraints(checkBoxIsBench, layoutCons); 324 checkBoxIsBench.addItemListener(this); 325 contentPane.add(checkBoxIsBench); 326 327 checkBoxIsShelder = new JCheckBox(tr(SHELDER_CAPTION)); 328 layoutCons.gridx = 1; 329 layoutCons.gridy = 10; 330 layoutCons.weightx = 0.5; 331 layoutCons.fill = GridBagConstraints.HORIZONTAL; 332 gridbag.setConstraints(checkBoxIsShelder, layoutCons); 333 checkBoxIsShelder.addItemListener(this); 334 contentPane.add(checkBoxIsShelder); 335 336 checkBoxIsCover = new JCheckBox(tr(COVER_CAPTION)); 337 layoutCons.gridx = 0; 338 layoutCons.gridy = 11; 339 layoutCons.weightx = 0.5; 340 layoutCons.fill = GridBagConstraints.HORIZONTAL; 341 gridbag.setConstraints(checkBoxIsCover, layoutCons); 342 checkBoxIsCover.addItemListener(this); 343 contentPane.add(checkBoxIsCover); 344 345 checkBoxIsArea = new JCheckBox(tr(AREA_CAPTION)); 346 layoutCons.gridx = 1; 347 layoutCons.gridy = 11; 348 layoutCons.weightx = 0.5; 349 layoutCons.fill = GridBagConstraints.HORIZONTAL; 350 gridbag.setConstraints(checkBoxIsArea, layoutCons); 351 checkBoxIsArea.addItemListener(this); 352 contentPane.add(checkBoxIsArea); 353 354 JButton buttonSave = new JButton(tr(SAVE_BUTTON_CAPTION)); 355 layoutCons.gridx = 0; 356 layoutCons.gridy = 12; 357 layoutCons.weightx = 0.5; 358 layoutCons.fill = GridBagConstraints.HORIZONTAL; 359 layoutCons.insets = new Insets(10, 0, 0, 0); 360 gridbag.setConstraints(buttonSave, layoutCons); 361 buttonSave.setActionCommand(SAVE_COMMAND); 362 buttonSave.addActionListener(this); 363 contentPane.add(buttonSave); 364 365 JButton buttonCancel = new JButton(tr(CANCEL_BUTTON_CAPTION)); 366 layoutCons.gridx = 1; 367 layoutCons.gridy = 12; 368 layoutCons.weightx = 0.5; 369 layoutCons.fill = GridBagConstraints.LINE_START; 370 layoutCons.insets = new Insets(10, 0, 0, 0); 371 gridbag.setConstraints(buttonCancel, layoutCons); 372 buttonCancel.setActionCommand(CANCEL_COMMAND); 373 buttonCancel.addActionListener(this); 374 contentPane.add(buttonCancel); 375 return contentPane; 376 } 377 378 /** 379 * Constructor of dialog with filling of controls 380 * 381 * @param customizeStopAction Stop area customizing action 382 * @param stopArea Stop area 383 */ 384 public CustomizePublicTransportStopDialog(CustomizeStopAction customizeStopAction, StopArea stopArea) { 385 this(); 386 setValues(stopArea); 387 this.customizeStopAction = customizeStopAction; 388 this.stopArea = stopArea; 389 } 390 391 /** 392 * Return stop area 393 * 394 * @return Stop area 395 */ 396 public StopArea getStopArea() { 397 return stopArea; 398 } 399 400 /** 401 * Set stop area and fill controls 402 * 403 * @param newStopArea Stop area 404 */ 405 public void setStopArea(StopArea newStopArea) { 406 setValues(newStopArea); 407 this.stopArea = newStopArea; 408 } 409 410 /** 411 * Returns stop area customizing action 412 * 413 * @return Stop area customizing action 414 */ 415 public CustomizeStopAction getCustomizeStopAction() { 416 return customizeStopAction; 417 } 418 419 /** 420 * Set stop area customizing action 421 * 422 * @param newCustomizeStopAction Stop area customizing action 423 */ 424 public void setCustomizeStopAction(CustomizeStopAction newCustomizeStopAction) { 425 customizeStopAction = newCustomizeStopAction; 426 } 427 428 /** 429 * Set value in check boxes map 430 * 431 * @param checkBox Check box 432 * @param value Value of check box 433 */ 434 public void setCheckBoxValue(JCheckBox checkBox, Boolean value) { 435 checkBoxValues.put(checkBox, value); 436 checkBox.setSelected(value); 437 } 438 439 /** 440 * Returns value of check box 441 * 442 * @param checkBox Check box 443 * @return Value of check box 444 */ 445 public Boolean getCheckBoxValue(JCheckBox checkBox) { 446 try { 447 if (checkBoxValues.containsKey(checkBox)) { 448 return checkBoxValues.get(checkBox); 449 } 450 return false; 451 } catch (Exception ex) { 452 MessageBox.ok(ex.getMessage()); 453 } 454 return false; 455 } 456 457 /** 458 * Callback method for check boxes Set values in check boxes map 459 */ 460 @Override 461 public void itemStateChanged(ItemEvent event) { 462 JCheckBox checkBox = (JCheckBox) event.getSource(); 463 if (event.getStateChange() == ItemEvent.DESELECTED) { 464 checkBoxValues.put(checkBox, false); 465 } else if (event.getStateChange() == ItemEvent.SELECTED) { 466 checkBoxValues.put(checkBox, true); 467 } 468 } 469 470 /** 471 * Show or hide dialog 472 * 473 * @param isVisible Flag of dialog visibility 474 */ 475 public void setVisible(Boolean isVisible) { 476 if (jDialog != null) 477 jDialog.setVisible(isVisible); 478 } 479 480 /** 481 * Get index of network level 482 * 483 * @param service Network level name 484 * @return Index of network level 485 */ 486 private int getServiceIndex(String service) { 487 for (int i = 0; i < serviceStrings.length; i++) { 488 if (serviceStrings[i].equals(service)) { 489 return i; 490 } 491 } 492 return 0; 493 } 494 495 /** 496 * Setting values of controls from stop area 497 * 498 * @param stopArea Stop area 499 */ 500 public void setValues(StopArea stopArea) { 501 if (stopArea == null) 502 return; 503 if (stopArea.name != null) 504 textFieldName.setText(stopArea.name); 505 else if (previousName != null) 506 textFieldName.setText(previousName); 507 if (stopArea.nameEn != null) 508 textFieldNameEn.setText(stopArea.nameEn); 509 else if (previousNameEn != null) 510 textFieldNameEn.setText(previousNameEn); 511 if (stopArea.network != null) 512 textFieldNetwork.setText(stopArea.network); 513 else if (previousNetwork != null) 514 textFieldNetwork.setText(previousNetwork); 515 if (stopArea.operator != null) 516 textFieldOperator.setText(stopArea.operator); 517 else if (previousOperator != null) 518 textFieldOperator.setText(previousOperator); 519 comboBoxService.setSelectedIndex(getServiceIndex(stopArea.service)); 520 setCheckBoxValue(checkBoxIsBus, stopArea.isBus); 521 setCheckBoxValue(checkBoxIsShareTaxi, stopArea.isShareTaxi); 522 setCheckBoxValue(checkBoxIsTrolleybus, stopArea.isTrolleybus); 523 setCheckBoxValue(checkBoxIsBusStation, stopArea.isBusStation); 524 setCheckBoxValue(checkBoxIsAssignTransportType, stopArea.isAssignTransportType); 525 setCheckBoxValue(checkBoxIsTram, stopArea.isTram); 526 setCheckBoxValue(checkBoxIsTrainStation, stopArea.isTrainStation); 527 setCheckBoxValue(checkBoxIsTrainStop, stopArea.isTrainStation); 528 setCheckBoxValue(checkBoxIsTrainStop, stopArea.isTrainStop); 529 setCheckBoxValue(checkBoxIsBench, stopArea.isBench); 530 setCheckBoxValue(checkBoxIsShelder, stopArea.isShelter); 531 setCheckBoxValue(checkBoxIsCover, stopArea.isCovered); 532 setCheckBoxValue(checkBoxIsArea, stopArea.isArea); 533 } 534 535 /** 536 * Returns text box value or null 537 * 538 * @param textField Text box 539 * @return Text box value or null 540 */ 541 public String getTextFromControl(JTextField textField) { 542 if (textField.getText().isEmpty()) 543 return null; 544 return textField.getText(); 545 } 546 547 /** 548 * Load values from controls and saving in stop area fields 549 * 550 * @return Stop area 551 */ 552 public StopArea saveValues() { 553 StopArea stopArea = this.stopArea; 554 try { 555 if (stopArea == null) 556 stopArea = new StopArea(); 557 stopArea.name = getTextFromControl(textFieldName); 558 previousName = stopArea.name; 559 stopArea.nameEn = getTextFromControl(textFieldNameEn); 560 previousNameEn = stopArea.nameEn; 561 stopArea.network = getTextFromControl(textFieldNetwork); 562 previousNetwork = stopArea.network; 563 stopArea.operator = getTextFromControl(textFieldOperator); 564 previousOperator = stopArea.operator; 565 stopArea.service = serviceStrings[comboBoxService.getSelectedIndex()]; 566 stopArea.isBus = getCheckBoxValue(checkBoxIsBus); 567 stopArea.isShareTaxi = getCheckBoxValue(checkBoxIsShareTaxi); 568 stopArea.isTrolleybus = getCheckBoxValue(checkBoxIsTrolleybus); 569 stopArea.isBusStation = getCheckBoxValue(checkBoxIsBusStation); 570 stopArea.isAssignTransportType = getCheckBoxValue(checkBoxIsAssignTransportType); 571 stopArea.isTram = getCheckBoxValue(checkBoxIsTram); 572 stopArea.isTrainStation = getCheckBoxValue(checkBoxIsTrainStation); 573 stopArea.isTrainStop = getCheckBoxValue(checkBoxIsTrainStop); 574 stopArea.isBench = getCheckBoxValue(checkBoxIsBench); 575 stopArea.isShelter = getCheckBoxValue(checkBoxIsShelder); 576 stopArea.isCovered = getCheckBoxValue(checkBoxIsCover); 577 stopArea.isArea = getCheckBoxValue(checkBoxIsArea); 578 } catch (Exception ex) { 579 MessageBox.ok(ex.getMessage()); 580 } 581 return stopArea; 582 } 583 584 /** 585 * Callback method for buttons event 586 */ 587 public void actionPerformed(ActionEvent event) { 588 if (SAVE_COMMAND.equals(event.getActionCommand())) { 589 setVisible(false); 590 if (customizeStopAction != null) { 591 StopArea stopArea = saveValues(); 592 customizeStopAction.performCustomizing(stopArea); 593 } 594 } else { 595 setVisible(false); 596 } 597 } 618 598 619 599 } -
applications/editors/josm/plugins/CustomizePublicTransportStop/src/ru/rodsoft/openstreetmap/josm/plugins/customizepublictransportstop/CustomizePublicTransportStopPlugin.java
r33811 r34156 1 // License: GPL. For details, see LICENSE file. 1 2 package ru.rodsoft.openstreetmap.josm.plugins.customizepublictransportstop; 2 3 … … 6 7 7 8 /** 9 * Class of plugin of customizing of stop area Plugin for josm editor 8 10 * 9 11 * @author Rodion Scherbakov 10 * Class of plugin of customizing of stop area11 * Plugin for josm editor12 12 */ 13 public class CustomizePublicTransportStopPlugin extends Plugin 14 { 15 /** 16 * Stop area customizing action 17 */ 18 private CustomizeStopAction stopAreaCreatorAction; 13 public class CustomizePublicTransportStopPlugin extends Plugin { 14 /** 15 * Stop area customizing action 16 */ 17 private CustomizeStopAction stopAreaCreatorAction; 19 18 20 /** 21 * Constructor of plug-in object 22 * @param info Plug-in properties 23 */ 19 /** 20 * Constructor of plug-in object 21 * 22 * @param info Plug-in properties 23 */ 24 24 public CustomizePublicTransportStopPlugin(PluginInformation info) { 25 25 super(info); … … 27 27 MainApplication.getMenu().toolsMenu.add(stopAreaCreatorAction); 28 28 } 29 29 30 30 } -
applications/editors/josm/plugins/CustomizePublicTransportStop/src/ru/rodsoft/openstreetmap/josm/plugins/customizepublictransportstop/CustomizeStopAction.java
r33990 r34156 1 // License: GPL. For details, see LICENSE file. 1 2 package ru.rodsoft.openstreetmap.josm.plugins.customizepublictransportstop; 2 3 … … 10 11 import org.openstreetmap.josm.tools.Shortcut; 11 12 12 import ru.rodsoft.openstreetmap.josm.plugins.customizepublictransportstop.CustomizePublicTransportStopDialog;13 14 13 /** 14 * Class of customizing of stop area Action for josm editor 15 15 * 16 16 * @author Rodion Scherbakov 17 * Class of customizing of stop area18 * Action for josm editor19 17 */ 20 public class CustomizeStopAction extends JosmAction implements IStopAreaCustomizer 21 { 18 public class CustomizeStopAction extends JosmAction implements IStopAreaCustomizer { 22 19 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 20 /** 21 * Menu icon file name 22 */ 23 private static final String CUSTOMIZE_STOP_ACTION_ICON_NAME = "bus.png"; 24 /** 25 * Menu item tooltip 26 */ 27 private static final String CUSTOMIZE_STOP_ACTION_MENU_TOOLTIP = "Customize stop under osm public transit standard v2"; 28 /** 29 * Menu item caption 30 */ 31 private static final String CUSTOMIZE_STOP_ACTION_MENU_NAME = "Customize stop"; 32 /** 33 * Serialization UID 34 */ 35 private static final long serialVersionUID = 6769508902749446137L; 39 36 40 41 42 * @param name Name of action in josm menu 43 iconName Name oficon file forjosm menu44 tooltip Tooltip of action injosm menu45 shortcut Short keyof actionon josm46 registerInToolbar Flag of registration in josm menu47 */ 48 protected CustomizeStopAction(String name, String iconName, String tooltip, 49 boolean registerInToolbar)50 37 /** 38 * Constructor of stop area customizing action 39 * 40 * @param name Name of action in josm menu 41 * @param iconName Name of icon file for josm menu 42 * @param tooltip Tooltip of action in josm menu 43 * @param shortcut Short key of action on josm 44 * @param registerInToolbar Flag of registration in josm menu 45 */ 46 protected CustomizeStopAction(String name, String iconName, String tooltip, Shortcut shortcut, 47 boolean registerInToolbar) { 51 48 super(name, iconName, tooltip, shortcut, registerInToolbar); 52 49 } … … 54 51 /** 55 52 * Constructs a stop area customizing action. 53 * 56 54 * @return the stop area customizing action 57 55 */ 58 public static CustomizeStopAction createCustomizeStopAction() 59 { 56 public static CustomizeStopAction createCustomizeStopAction() { 60 57 // CHECKSTYLE.OFF: LineLength 61 62 tr(CUSTOMIZE_STOP_ACTION_MENU_NAME),CUSTOMIZE_STOP_ACTION_ICON_NAME,63 tr(CUSTOMIZE_STOP_ACTION_MENU_ TOOLTIP),64 Shortcut.registerShortcut("tools:customizestop", tr("Tool: {0}", tr(CUSTOMIZE_STOP_ACTION_MENU_NAME)),KeyEvent.VK_U, Shortcut.DIRECT),58 CustomizeStopAction action = new CustomizeStopAction(tr(CUSTOMIZE_STOP_ACTION_MENU_NAME), 59 CUSTOMIZE_STOP_ACTION_ICON_NAME, tr(CUSTOMIZE_STOP_ACTION_MENU_TOOLTIP), 60 Shortcut.registerShortcut("tools:customizestop", tr("Tool: {0}", tr(CUSTOMIZE_STOP_ACTION_MENU_NAME)), 61 KeyEvent.VK_U, Shortcut.DIRECT), 65 62 true); 66 63 action.putValue("help", ht("/Action/CustomizeStopAction")); … … 70 67 71 68 /** 72 * Realization of action 73 * Construct stop area object from selected object andshow settings dialog69 * Realization of action Construct stop area object from selected object and 70 * show settings dialog 74 71 */ 75 72 @Override 76 77 {78 if (!isEnabled()) 79 return; 80 CreateStopAreaFromSelectedObjectOperation createStopAreaFromSelectedObjectOperation = new CreateStopAreaFromSelectedObjectOperation(getLayerManager().getEditDataSet());81 82 if(stopArea == null)83 84 85 86 73 public void actionPerformed(ActionEvent arg0) { 74 if (!isEnabled()) 75 return; 76 CreateStopAreaFromSelectedObjectOperation createStopAreaFromSelectedObjectOperation = new CreateStopAreaFromSelectedObjectOperation( 77 getLayerManager().getEditDataSet()); 78 StopArea stopArea = createStopAreaFromSelectedObjectOperation.performCustomizing(null); 79 if (stopArea == null) 80 return; 81 CustomizePublicTransportStopDialog dialog = new CustomizePublicTransportStopDialog(this, stopArea); 82 dialog.setVisible(true); 83 } 87 84 88 /** 89 * Perform stop area customizing under user selection 90 * This method is launched by stop area settings dialog 91 * @param stopArea Stop area object with new settings 92 */ 93 @Override 94 public StopArea performCustomizing(StopArea stopArea) 95 { 96 CustomizeStopAreaOperation customizeStopAreaOperation = new CustomizeStopAreaOperation(getLayerManager().getEditDataSet()); 97 return customizeStopAreaOperation.performCustomizing(stopArea); 98 } 99 85 /** 86 * Perform stop area customizing under user selection This method is launched by 87 * stop area settings dialog 88 * 89 * @param stopArea Stop area object with new settings 90 */ 91 @Override 92 public StopArea performCustomizing(StopArea stopArea) { 93 CustomizeStopAreaOperation customizeStopAreaOperation = new CustomizeStopAreaOperation( 94 getLayerManager().getEditDataSet()); 95 return customizeStopAreaOperation.performCustomizing(stopArea); 96 } 97 100 98 } -
applications/editors/josm/plugins/CustomizePublicTransportStop/src/ru/rodsoft/openstreetmap/josm/plugins/customizepublictransportstop/CustomizeStopAreaOperation.java
r33811 r34156 1 // License: GPL. For details, see LICENSE file. 1 2 package ru.rodsoft.openstreetmap.josm.plugins.customizepublictransportstop; 2 3 … … 20 21 import org.openstreetmap.josm.data.osm.Way; 21 22 import org.openstreetmap.josm.gui.MainApplication; 23 import org.openstreetmap.josm.tools.Logging; 22 24 23 25 /** 24 * Operation of creation and customizing stop area relation and its members under user selection 26 * Operation of creation and customizing stop area relation and its members 27 * under user selection 28 * 25 29 * @author Rodion Scherbakov 26 30 */ 27 public class CustomizeStopAreaOperation extends StopAreaOperationBase 28 { 29 30 /** 31 * Operation name in undo list 32 */ 31 public class CustomizeStopAreaOperation extends StopAreaOperationBase { 32 33 /** 34 * Operation name in undo list 35 */ 33 36 private static final String TAG_ASSIGN_COMMAND_NAME = "Stop area tag assign"; 34 37 35 /** 36 * Constructor of operation object 37 * @param currentDataSet Current Josm data set 38 */ 39 public CustomizeStopAreaOperation(DataSet currentDataSet) 40 { 41 super(currentDataSet); 42 } 43 44 /** 45 * Forming commands for josm for saving name and name:en attributes stop of area members and relation attributes 46 * @param target Stop area member or relation 47 * @param commands List of commands 48 * @param stopArea Stop area object 49 * @return Resulting list of commands 50 */ 51 public List<Command> nameTagAssign(OsmPrimitive target, List<Command> commands, StopArea stopArea) 52 { 53 if(commands == null) 54 commands = new ArrayList<Command>(); 55 56 commands = assignTag(commands, target, OSMTags.NAME_TAG, "".equals(stopArea.name) ? null : stopArea.name); 57 commands = assignTag(commands, target, OSMTags.NAME_EN_TAG, "".equals(stopArea.nameEn) ? null : stopArea.nameEn); 58 return commands; 59 } 60 38 /** 39 * Constructor of operation object 40 * 41 * @param currentDataSet Current Josm data set 42 */ 43 public CustomizeStopAreaOperation(DataSet currentDataSet) { 44 super(currentDataSet); 45 } 46 47 /** 48 * Forming commands for josm for saving name and name:en attributes stop of area 49 * members and relation attributes 50 * 51 * @param target Stop area member or relation 52 * @param commands List of commands 53 * @param stopArea Stop area object 54 * @return Resulting list of commands 55 */ 56 public List<Command> nameTagAssign(OsmPrimitive target, List<Command> commands, StopArea stopArea) { 57 if (commands == null) 58 commands = new ArrayList<Command>(); 59 60 commands = assignTag(commands, target, OSMTags.NAME_TAG, "".equals(stopArea.name) ? null : stopArea.name); 61 commands = assignTag(commands, target, OSMTags.NAME_EN_TAG, 62 "".equals(stopArea.nameEn) ? null : stopArea.nameEn); 63 return commands; 64 } 65 61 66 /** 62 67 * Clear transport type tags 63 * @param target Josm object for tag clearing 68 * 69 * @param target Josm object for tag clearing 64 70 * @param commands Command list 65 71 * @return Resulting list of commands 66 72 */ 67 protected List<Command> transportTypeTagClearing(OsmPrimitive target, 68 List<Command> commands) { 69 commands = clearTag(commands, target, OSMTags.BUS_TAG); 70 commands = clearTag(commands, target, OSMTags.SHARE_TAXI_TAG); 71 commands = clearTag(commands, target, OSMTags.TROLLEYBUS_TAG); 72 commands = clearTag(commands, target, OSMTags.TRAM_TAG); 73 commands = clearTag(commands, target, OSMTags.TRAIN_TAG); 74 return commands; 75 } 76 77 /** 73 protected List<Command> transportTypeTagClearing(OsmPrimitive target, List<Command> commands) { 74 commands = clearTag(commands, target, OSMTags.BUS_TAG); 75 commands = clearTag(commands, target, OSMTags.SHARE_TAXI_TAG); 76 commands = clearTag(commands, target, OSMTags.TROLLEYBUS_TAG); 77 commands = clearTag(commands, target, OSMTags.TRAM_TAG); 78 commands = clearTag(commands, target, OSMTags.TRAIN_TAG); 79 return commands; 80 } 81 82 /** 78 83 * Assign transport type tags to node 79 * @param target Josm object for tag assigning 84 * 85 * @param target Josm object for tag assigning 80 86 * @param commands Command list 81 87 * @param stopArea Stop area object 82 88 * @param isStopPoint Flag of stop point 83 * @return Resulting list of commands 84 */ 85 protected List<Command> transportTypeTagAssign(OsmPrimitive target, List<Command> commands, StopArea stopArea, Boolean isStopPoint) 86 { 87 if(commands == null) 88 commands = new ArrayList<Command>(); 89 90 if(isStopPoint) 91 { 92 if(stopArea.isTrainStop || stopArea.isTrainStation) 93 { 94 commands = clearTag(commands, target, OSMTags.BUS_TAG); 95 commands = clearTag(commands, target, OSMTags.SHARE_TAXI_TAG); 96 commands = clearTag(commands, target, OSMTags.TROLLEYBUS_TAG); 97 commands = clearTag(commands, target, OSMTags.TRAM_TAG); 98 commands = assignTag(commands, target, OSMTags.TRAIN_TAG, OSMTags.YES_TAG_VALUE); 99 } 100 else 101 { 102 commands = assignTag(commands, target, OSMTags.BUS_TAG, stopArea.isBus ? OSMTags.YES_TAG_VALUE : null); 103 commands = assignTag(commands, target, OSMTags.SHARE_TAXI_TAG, stopArea.isShareTaxi ? OSMTags.YES_TAG_VALUE : null); 104 commands = assignTag(commands, target, OSMTags.TROLLEYBUS_TAG, stopArea.isTrolleybus ? OSMTags.YES_TAG_VALUE : null); 105 commands = assignTag(commands, target, OSMTags.TRAM_TAG, stopArea.isTram ? OSMTags.YES_TAG_VALUE : null); 106 commands = assignTag(commands, target, OSMTags.TRAIN_TAG, stopArea.isTrainStation || stopArea.isTrainStop ? OSMTags.YES_TAG_VALUE : null); 107 } 108 } 109 else 110 { 111 if(stopArea.isAssignTransportType) 112 { 113 commands = assignTag(commands, target, OSMTags.BUS_TAG, stopArea.isBus ? OSMTags.YES_TAG_VALUE : null); 114 commands = assignTag(commands, target, OSMTags.SHARE_TAXI_TAG, stopArea.isShareTaxi ? OSMTags.YES_TAG_VALUE : null); 115 commands = assignTag(commands, target, OSMTags.TROLLEYBUS_TAG, stopArea.isTrolleybus ? OSMTags.YES_TAG_VALUE : null); 116 commands = assignTag(commands, target, OSMTags.TRAM_TAG, stopArea.isTram ? OSMTags.YES_TAG_VALUE : null); 117 commands = assignTag(commands, target, OSMTags.TRAIN_TAG, stopArea.isTrainStation || stopArea.isTrainStop ? OSMTags.YES_TAG_VALUE : null); 118 } 119 else 120 { 121 commands = transportTypeTagClearing(target, commands); 122 } 123 } 124 return commands; 125 } 126 127 /** 128 * Forming commands for josm for saving general attributes of stop area members and relation 129 * @param target Stop area member or relation 130 * @param commands List of commands 131 * @param stopArea Stop area object 132 * @return Resulting list of commands 133 */ 134 public List<Command> generalTagAssign(OsmPrimitive target, List<Command> commands, StopArea stopArea) 135 { 136 if(commands == null) 137 commands = new ArrayList<Command>(); 138 139 commands = nameTagAssign(target,commands, stopArea); 140 commands = assignTag(commands, target, OSMTags.NETWORK_TAG, "".equals(stopArea.network) ? null : stopArea.network); 141 commands = assignTag(commands, target, OSMTags.OPERATOR_TAG, "".equals(stopArea.operator) ? null : stopArea.operator); 142 commands = assignTag(commands, target, OSMTags.SERVICE_TAG, null == stopArea.service || OSMTags.CITY_NETWORK_TAG_VALUE.equals(stopArea.service) ? null : stopArea.service); 143 144 return commands; 145 } 146 147 89 * @return Resulting list of commands 90 */ 91 protected List<Command> transportTypeTagAssign(OsmPrimitive target, List<Command> commands, StopArea stopArea, 92 Boolean isStopPoint) { 93 if (commands == null) 94 commands = new ArrayList<Command>(); 95 96 if (isStopPoint) { 97 if (stopArea.isTrainStop || stopArea.isTrainStation) { 98 commands = clearTag(commands, target, OSMTags.BUS_TAG); 99 commands = clearTag(commands, target, OSMTags.SHARE_TAXI_TAG); 100 commands = clearTag(commands, target, OSMTags.TROLLEYBUS_TAG); 101 commands = clearTag(commands, target, OSMTags.TRAM_TAG); 102 commands = assignTag(commands, target, OSMTags.TRAIN_TAG, OSMTags.YES_TAG_VALUE); 103 } else { 104 commands = assignTag(commands, target, OSMTags.BUS_TAG, stopArea.isBus ? OSMTags.YES_TAG_VALUE : null); 105 commands = assignTag(commands, target, OSMTags.SHARE_TAXI_TAG, 106 stopArea.isShareTaxi ? OSMTags.YES_TAG_VALUE : null); 107 commands = assignTag(commands, target, OSMTags.TROLLEYBUS_TAG, 108 stopArea.isTrolleybus ? OSMTags.YES_TAG_VALUE : null); 109 commands = assignTag(commands, target, OSMTags.TRAM_TAG, 110 stopArea.isTram ? OSMTags.YES_TAG_VALUE : null); 111 commands = assignTag(commands, target, OSMTags.TRAIN_TAG, 112 stopArea.isTrainStation || stopArea.isTrainStop ? OSMTags.YES_TAG_VALUE : null); 113 } 114 } else { 115 if (stopArea.isAssignTransportType) { 116 commands = assignTag(commands, target, OSMTags.BUS_TAG, stopArea.isBus ? OSMTags.YES_TAG_VALUE : null); 117 commands = assignTag(commands, target, OSMTags.SHARE_TAXI_TAG, 118 stopArea.isShareTaxi ? OSMTags.YES_TAG_VALUE : null); 119 commands = assignTag(commands, target, OSMTags.TROLLEYBUS_TAG, 120 stopArea.isTrolleybus ? OSMTags.YES_TAG_VALUE : null); 121 commands = assignTag(commands, target, OSMTags.TRAM_TAG, 122 stopArea.isTram ? OSMTags.YES_TAG_VALUE : null); 123 commands = assignTag(commands, target, OSMTags.TRAIN_TAG, 124 stopArea.isTrainStation || stopArea.isTrainStop ? OSMTags.YES_TAG_VALUE : null); 125 } else { 126 commands = transportTypeTagClearing(target, commands); 127 } 128 } 129 return commands; 130 } 131 132 /** 133 * Forming commands for josm for saving general attributes of stop area members 134 * and relation 135 * 136 * @param target Stop area member or relation 137 * @param commands List of commands 138 * @param stopArea Stop area object 139 * @return Resulting list of commands 140 */ 141 public List<Command> generalTagAssign(OsmPrimitive target, List<Command> commands, StopArea stopArea) { 142 if (commands == null) 143 commands = new ArrayList<Command>(); 144 145 commands = nameTagAssign(target, commands, stopArea); 146 commands = assignTag(commands, target, OSMTags.NETWORK_TAG, 147 "".equals(stopArea.network) ? null : stopArea.network); 148 commands = assignTag(commands, target, OSMTags.OPERATOR_TAG, 149 "".equals(stopArea.operator) ? null : stopArea.operator); 150 commands = assignTag(commands, target, OSMTags.SERVICE_TAG, 151 null == stopArea.service || OSMTags.CITY_NETWORK_TAG_VALUE.equals(stopArea.service) ? null 152 : stopArea.service); 153 154 return commands; 155 } 156 148 157 /** 149 158 * Forming commands for josm for saving stop position attributes 159 * 150 160 * @param target Stop position node 151 161 * @param commands Original command list 152 162 * @param stopArea Stop area object 153 163 * @param isFirst true, if target is first stop position in stop area 154 164 * @return Resulting command list 155 165 */ 156 public List<Command> stopPointTagAssign(OsmPrimitive target, List<Command> commands, StopArea stopArea, Boolean isFirst) 157 { 158 if(commands == null) 159 commands = new ArrayList<Command>(); 160 161 commands = generalTagAssign(target, commands, stopArea); 162 commands = transportTypeTagAssign(target, commands, stopArea, true); 163 if(isFirst) 164 { 165 if(stopArea.isTrainStop) 166 { 167 commands = assignTag(commands, target, OSMTags.RAILWAY_TAG, OSMTags.HALT_TAG_VALUE); 168 } 169 else 170 if(stopArea.isTrainStation) 171 { 172 commands = assignTag(commands, target, OSMTags.RAILWAY_TAG, OSMTags.STATION_TAG_VALUE); 173 } 174 else 175 if(stopArea.isTram) 176 commands = assignTag(commands, target, OSMTags.RAILWAY_TAG, OSMTags.TRAM_STOP_TAG_VALUE); 177 else 178 commands = clearTag(commands, target, OSMTags.RAILWAY_TAG); 179 } 180 else 181 { 182 commands = clearTag(commands, target, OSMTags.RAILWAY_TAG); 183 } 184 if(compareTag(target, OSMTags.HIGHWAY_TAG, OSMTags.BUS_STOP_TAG_VALUE)) 185 commands = clearTag(commands, target, OSMTags.HIGHWAY_TAG); 186 if(compareTag(target, OSMTags.AMENITY_TAG, OSMTags.BUS_STATION_TAG_VALUE)) 187 commands = clearTag(commands, target, OSMTags.AMENITY_TAG); 188 commands = assignTag(commands, target, OSMTags.PUBLIC_TRANSPORT_TAG, OSMTags.STOP_POSITION_TAG_VALUE); 189 return commands; 190 } 191 166 public List<Command> stopPointTagAssign(OsmPrimitive target, List<Command> commands, StopArea stopArea, 167 Boolean isFirst) { 168 if (commands == null) 169 commands = new ArrayList<Command>(); 170 171 commands = generalTagAssign(target, commands, stopArea); 172 commands = transportTypeTagAssign(target, commands, stopArea, true); 173 if (isFirst) { 174 if (stopArea.isTrainStop) { 175 commands = assignTag(commands, target, OSMTags.RAILWAY_TAG, OSMTags.HALT_TAG_VALUE); 176 } else if (stopArea.isTrainStation) { 177 commands = assignTag(commands, target, OSMTags.RAILWAY_TAG, OSMTags.STATION_TAG_VALUE); 178 } else if (stopArea.isTram) 179 commands = assignTag(commands, target, OSMTags.RAILWAY_TAG, OSMTags.TRAM_STOP_TAG_VALUE); 180 else 181 commands = clearTag(commands, target, OSMTags.RAILWAY_TAG); 182 } else { 183 commands = clearTag(commands, target, OSMTags.RAILWAY_TAG); 184 } 185 if (compareTag(target, OSMTags.HIGHWAY_TAG, OSMTags.BUS_STOP_TAG_VALUE)) 186 commands = clearTag(commands, target, OSMTags.HIGHWAY_TAG); 187 if (compareTag(target, OSMTags.AMENITY_TAG, OSMTags.BUS_STATION_TAG_VALUE)) 188 commands = clearTag(commands, target, OSMTags.AMENITY_TAG); 189 commands = assignTag(commands, target, OSMTags.PUBLIC_TRANSPORT_TAG, OSMTags.STOP_POSITION_TAG_VALUE); 190 return commands; 191 } 192 192 193 /** 193 194 * Forming commands for josm for saving platform attributes 195 * 194 196 * @param target Platform node or way 195 197 * @param commands Original command list 196 198 * @param stopArea Stop area object 197 199 * @param isSelected true, if this platform is selected in editor 198 200 * @param isFirst true, if this platform is first in stop area 199 201 * @return Resulting command list 200 202 */ 201 public List<Command> platformTagAssign(OsmPrimitive target, List<Command> commands, StopArea stopArea, Boolean isFirst) 202 { 203 if(commands == null) 204 commands = new ArrayList<Command>(); 205 206 commands = generalTagAssign(target, commands, stopArea); 207 commands = transportTypeTagAssign(target, commands, stopArea, false); 208 209 if(compareTag(target, OSMTags.RAILWAY_TAG, OSMTags.HALT_TAG_VALUE) || compareTag(target, OSMTags.RAILWAY_TAG, OSMTags.STATION_TAG_VALUE)) 210 commands = clearTag(commands, target, OSMTags.RAILWAY_TAG); 211 if(target instanceof Way && (stopArea.isTrainStop || stopArea.isTrainStation || stopArea.isTram)) 212 commands = assignTag(commands, target, OSMTags.RAILWAY_TAG, OSMTags.PLATFORM_TAG_VALUE); 213 if(stopArea.isBus || stopArea.isShareTaxi || stopArea.isTrolleybus) 214 { 215 if(target instanceof Way) 216 commands = assignTag(commands, target, OSMTags.HIGHWAY_TAG, OSMTags.PLATFORM_TAG_VALUE); 217 else 218 if(isFirst && !stopArea.isBusStation) 219 commands = assignTag(commands, target, OSMTags.HIGHWAY_TAG, OSMTags.BUS_STOP_TAG_VALUE); 220 } 221 commands = assignTag(commands, target, OSMTags.PUBLIC_TRANSPORT_TAG, OSMTags.PLATFORM_TAG_VALUE); 222 if(target == stopArea.selectedObject) 223 { 224 commands = assignTag(commands, target, OSMTags.BENCH_TAG, stopArea.isBench ? OSMTags.YES_TAG_VALUE : null); 225 commands = assignTag(commands, target, OSMTags.SHELTER_TAG, stopArea.isShelter ? OSMTags.YES_TAG_VALUE : null); 226 commands = assignTag(commands, target, OSMTags.COVERED_TAG, stopArea.isCovered ? OSMTags.YES_TAG_VALUE : null); 227 commands = assignTag(commands, target, OSMTags.AREA_TAG, stopArea.isArea ? OSMTags.YES_TAG_VALUE : null); 228 } 229 return commands; 230 } 231 232 /** 233 * Forming commands for josm for saving attributes of non stop position or platform 234 * @param target Member of stop area relation 235 * @param commands Original command list 236 * @param stopArea Stop area object 237 * @return Resulting command list 238 */ 239 public List<Command> otherMemberTagAssign(OsmPrimitive target, List<Command> commands, StopArea stopArea) 240 { 241 if(commands == null) 242 commands = new ArrayList<Command>(); 243 244 commands = nameTagAssign(target, commands, stopArea); 245 commands = clearTag(commands, target, OSMTags.NETWORK_TAG); 246 commands = clearTag(commands, target, OSMTags.OPERATOR_TAG); 247 commands = clearTag(commands, target, OSMTags.SERVICE_TAG); 248 if(compareTag(target, OSMTags.RAILWAY_TAG, OSMTags.HALT_TAG_VALUE) || compareTag(target, OSMTags.RAILWAY_TAG, OSMTags.STATION_TAG_VALUE)) 249 commands = clearTag(commands, target, OSMTags.RAILWAY_TAG); 250 return commands; 251 } 252 203 public List<Command> platformTagAssign(OsmPrimitive target, List<Command> commands, StopArea stopArea, 204 Boolean isFirst) { 205 if (commands == null) 206 commands = new ArrayList<Command>(); 207 208 commands = generalTagAssign(target, commands, stopArea); 209 commands = transportTypeTagAssign(target, commands, stopArea, false); 210 211 if (compareTag(target, OSMTags.RAILWAY_TAG, OSMTags.HALT_TAG_VALUE) 212 || compareTag(target, OSMTags.RAILWAY_TAG, OSMTags.STATION_TAG_VALUE)) 213 commands = clearTag(commands, target, OSMTags.RAILWAY_TAG); 214 if (target instanceof Way && (stopArea.isTrainStop || stopArea.isTrainStation || stopArea.isTram)) 215 commands = assignTag(commands, target, OSMTags.RAILWAY_TAG, OSMTags.PLATFORM_TAG_VALUE); 216 if (stopArea.isBus || stopArea.isShareTaxi || stopArea.isTrolleybus) { 217 if (target instanceof Way) 218 commands = assignTag(commands, target, OSMTags.HIGHWAY_TAG, OSMTags.PLATFORM_TAG_VALUE); 219 else if (isFirst && !stopArea.isBusStation) 220 commands = assignTag(commands, target, OSMTags.HIGHWAY_TAG, OSMTags.BUS_STOP_TAG_VALUE); 221 } 222 commands = assignTag(commands, target, OSMTags.PUBLIC_TRANSPORT_TAG, OSMTags.PLATFORM_TAG_VALUE); 223 if (target == stopArea.selectedObject) { 224 commands = assignTag(commands, target, OSMTags.BENCH_TAG, stopArea.isBench ? OSMTags.YES_TAG_VALUE : null); 225 commands = assignTag(commands, target, OSMTags.SHELTER_TAG, 226 stopArea.isShelter ? OSMTags.YES_TAG_VALUE : null); 227 commands = assignTag(commands, target, OSMTags.COVERED_TAG, 228 stopArea.isCovered ? OSMTags.YES_TAG_VALUE : null); 229 commands = assignTag(commands, target, OSMTags.AREA_TAG, stopArea.isArea ? OSMTags.YES_TAG_VALUE : null); 230 } 231 return commands; 232 } 233 234 /** 235 * Forming commands for josm for saving attributes of non stop position or 236 * platform 237 * 238 * @param target Member of stop area relation 239 * @param commands Original command list 240 * @param stopArea Stop area object 241 * @return Resulting command list 242 */ 243 public List<Command> otherMemberTagAssign(OsmPrimitive target, List<Command> commands, StopArea stopArea) { 244 if (commands == null) 245 commands = new ArrayList<Command>(); 246 247 commands = nameTagAssign(target, commands, stopArea); 248 commands = clearTag(commands, target, OSMTags.NETWORK_TAG); 249 commands = clearTag(commands, target, OSMTags.OPERATOR_TAG); 250 commands = clearTag(commands, target, OSMTags.SERVICE_TAG); 251 if (compareTag(target, OSMTags.RAILWAY_TAG, OSMTags.HALT_TAG_VALUE) 252 || compareTag(target, OSMTags.RAILWAY_TAG, OSMTags.STATION_TAG_VALUE)) 253 commands = clearTag(commands, target, OSMTags.RAILWAY_TAG); 254 return commands; 255 } 256 253 257 /** 254 258 * Forming commands for josm for saving stop area relation attributes 255 * @param commands Original command list 256 * @param stopArea Stop area object 257 * @return Resulting command list 258 */ 259 private List<Command> createStopAreaRelation(List<Command> commands, StopArea stopArea) 260 { 261 if(commands == null) 262 commands = new ArrayList<Command>(); 263 264 Relation newRelation = new Relation(); 265 for(Node node : stopArea.stopPoints) 266 { 267 newRelation.addMember(new RelationMember(OSMTags.STOP_ROLE, node)); 268 } 269 for(OsmPrimitive platform : stopArea.platforms) 270 { 271 newRelation.addMember(new RelationMember(OSMTags.PLATFORM_ROLE, platform)); 272 } 273 for(OsmPrimitive otherMember : stopArea.otherMembers) 274 { 275 newRelation.addMember(new RelationMember("", otherMember)); 276 } 277 Main.main.undoRedo.add(new AddCommand(MainApplication.getLayerManager().getEditDataSet(), newRelation)); 278 commands = generalTagAssign(newRelation, commands, stopArea); 279 commands = assignTag(commands, newRelation, OSMTags.TYPE_TAG, OSMTags.PUBLIC_TRANSPORT_TAG); 280 commands = assignTag(commands, newRelation, OSMTags.PUBLIC_TRANSPORT_TAG, OSMTags.STOP_AREA_TAG_VALUE); 281 return commands; 282 } 283 284 /** 285 * Adding of new stop area members to relation 286 * @param commands Original command list 287 * @param targetRelation Stop area relation 288 * @param member Stop area relation member 289 * @param roleName Role name 290 * @return Resulting command list 291 */ 292 public static List<Command> addNewRelationMember(List<Command> commands, Relation targetRelation, OsmPrimitive member, String roleName) 293 { 294 if(commands == null) 295 commands = new ArrayList<Command>(); 296 297 for(RelationMember relationMember : targetRelation.getMembers()) 298 { 299 if(relationMember.getMember() == member) 300 { 301 if(relationMember.getRole() == roleName) 302 { 303 return commands; 304 } 305 return commands; 306 } 307 } 308 targetRelation.addMember(new RelationMember(roleName, member)); 309 commands.add(new ChangeCommand(targetRelation, targetRelation)); 310 return commands; 311 } 312 313 /** 314 * Adding new stop area members to relation 315 * @param commands Original command list 316 * @param stopArea Stop area object 317 * @return Resulting command list 318 */ 319 private List<Command> addNewRelationMembers(List<Command> commands, StopArea stopArea) 320 { 321 if(commands == null) 322 commands = new ArrayList<Command>(); 323 324 for(OsmPrimitive stopPoint : stopArea.stopPoints) 325 { 326 commands = addNewRelationMember(commands, stopArea.stopAreaRelation, stopPoint, OSMTags.STOP_ROLE); 327 } 328 for(OsmPrimitive platform : stopArea.platforms) 329 { 330 commands = addNewRelationMember(commands, stopArea.stopAreaRelation, platform, OSMTags.PLATFORM_ROLE); 331 } 332 for(OsmPrimitive otherMember : stopArea.otherMembers) 333 { 334 commands = addNewRelationMember(commands, stopArea.stopAreaRelation, otherMember, null); 335 } 336 return commands; 337 } 338 339 /** 340 * Testing, is josm object bus stop node or contains bus stop node, defined by tag and its value 341 * @param member Josm object 342 * @param tag Tag name 343 * @param tagValue Tag value 344 * @return true, if josm object is bus stop node or contains bus stop node 345 */ 346 private Node searchBusStop(OsmPrimitive member, String tag, String tagValue) 347 { 348 if(member instanceof Node) 349 { 350 if(compareTag(member, tag, tagValue)) 351 { 352 return (Node)member; 353 } 354 } 355 else 356 { 357 Way memberWay = (Way) member; 358 for(Node node : memberWay.getNodes()) 359 { 360 if(compareTag(node, tag, tagValue)) 361 { 362 return node; 363 } 364 } 365 } 366 return null; 367 } 368 369 /** 370 * Testing, do stop area contains bus stop node, defined by tag and its value 371 * @param tag Tag name 372 * @param tagValue Tag value 373 * @return true, if stop area contains bus stop node 374 */ 375 public Node searchBusStop(StopArea stopArea, String tag, String tagValue) 376 { 377 for(OsmPrimitive platform : stopArea.platforms) 378 { 379 Node busStopNode = searchBusStop(platform, tag, tagValue); 380 if(busStopNode != null) 381 return busStopNode; 382 } 383 for(OsmPrimitive otherMember : stopArea.otherMembers) 384 { 385 Node busStopNode = searchBusStop(otherMember, tag, tagValue); 386 if(busStopNode != null) 387 return busStopNode; 388 } 389 return null; 390 } 391 392 /** 393 * Testing, must stop area to have separate bus stop node 394 * @param stopArea Stop area object 395 * @param firstPlatform First platform of stop area JOSM object 396 * @return True, stop area must to have separate bus stop node 397 */ 398 public boolean needSeparateBusStop(StopArea stopArea, OsmPrimitive firstPlatform) 399 { 400 if(((stopArea.isBus || stopArea.isShareTaxi || stopArea.isTrolleybus) && (firstPlatform instanceof Way))) 401 { 402 return true; 403 } 404 return false; 405 } 406 407 /** 408 * Clear excess tags from JOSM object and its nodes 409 * @param commands Original command list 410 * @param target JOSM object 411 * @param tag Tag name 412 * @param tagValue Tag value 413 * @return Resulting command list 414 */ 415 private List<Command> clearExcessTags(List<Command> commands, OsmPrimitive target, String tag, String tagValue) 416 { 417 if(commands == null) 418 commands = new ArrayList<Command>(); 419 420 if(compareTag(target, tag, tagValue)) 421 { 422 commands = clearTag(commands, target, tag); 423 } 424 if(target instanceof Way) 425 { 426 Way memberWay = (Way) target; 427 for(Node node : memberWay.getNodes()) 428 { 429 if(compareTag(node, tag, tagValue)) 430 { 431 commands = clearTag(commands, target, tag); 432 } 433 } 434 } 435 return commands; 436 } 437 438 /** 439 * Clear excess tags from JOSM object and its nodes 440 * @param commands Command list 441 * @param stopArea Stop area object 442 * @param tag Tag name 443 * @param tagValue Tag value 444 * @return Resulting command list 445 */ 446 public List<Command> clearExcessTags(List<Command> commands, StopArea stopArea, String tag, String tagValue) 447 { 448 if(commands == null) 449 commands = new ArrayList<Command>(); 450 451 for(OsmPrimitive stopPoint : stopArea.stopPoints) 452 { 453 clearExcessTags(commands, stopPoint, tag, tagValue); 454 } 455 for(OsmPrimitive platform : stopArea.platforms) 456 { 457 clearExcessTags(commands, platform, tag, tagValue); 458 } 459 for(OsmPrimitive otherMember : stopArea.otherMembers) 460 { 461 clearExcessTags(commands, otherMember, tag, tagValue); 462 } 463 return commands; 464 } 465 466 467 /** 468 * Create separate bus stop node or assign bus stop tag to platform node 469 * @param commands Original command list 470 * @param stopArea Stop area object 471 * @param firstPlatform First platform in stop area relation 472 * @param tag Tag name 473 * @param tagValue Tag value 474 * @return Resulting command list 475 */ 476 protected List<Command> createSeparateBusStopNode(List<Command> commands, StopArea stopArea, OsmPrimitive firstPlatform, String tag, String tagValue) 477 { 478 if(commands == null) 479 commands = new ArrayList<Command>(); 480 481 LatLon centerOfPlatform = getCenterOfWay(firstPlatform); 482 if(firstPlatform instanceof Way) 483 { 484 if(centerOfPlatform != null) 485 { 486 Node newNode =new Node(); 487 newNode.setCoor(centerOfPlatform); 488 Main.main.undoRedo.add(new AddCommand(MainApplication.getLayerManager().getEditDataSet(), newNode)); 489 Main.main.undoRedo.add(new ChangePropertyCommand(newNode, tag, tagValue)); 490 commands = assignTag(commands, newNode, tag, tagValue); 491 stopArea.otherMembers.add(newNode); 492 } 493 } 494 else 495 { 496 commands = assignTag(commands, firstPlatform, tag, tagValue); 497 } 498 return commands; 499 } 500 501 /** 502 * Forming commands for JOSM for saving stop area members and relation attributes 503 * @param stopArea Stop area object 504 * @return Resulting command list 505 */ 506 public List<Command> customize(StopArea stopArea) 507 { 508 try 509 { 510 List<Command> commands = new ArrayList<Command>(); 511 Node separateBusStopNode = searchBusStop(stopArea, OSMTags.AMENITY_TAG, OSMTags.BUS_STATION_TAG_VALUE); 512 if(separateBusStopNode == null) 513 separateBusStopNode = searchBusStop(stopArea, OSMTags.HIGHWAY_TAG, OSMTags.BUS_STOP_TAG_VALUE); 514 if(stopArea.isBusStation) 515 { 516 commands = clearExcessTags(commands, stopArea, OSMTags.HIGHWAY_TAG, OSMTags.BUS_STOP_TAG_VALUE); 517 } 518 else 519 { 520 commands = clearExcessTags(commands, stopArea, OSMTags.AMENITY_TAG, OSMTags.BUS_STATION_TAG_VALUE); 521 } 522 if(!(stopArea.isBus || stopArea.isShareTaxi || stopArea.isTrolleybus)) 523 { 524 commands = clearExcessTags(commands, stopArea, OSMTags.HIGHWAY_TAG, OSMTags.BUS_STOP_TAG_VALUE); 525 } 526 if(stopArea.stopPoints.size() == 0) 527 { 528 CreateNewStopPointOperation createNewStopPointOperation = new CreateNewStopPointOperation(getCurrentDataSet()); 529 createNewStopPointOperation.performCustomizing(stopArea); 530 } 531 Boolean isFirst = true; 532 for(Node node : stopArea.stopPoints) 533 { 534 commands = stopPointTagAssign(node, commands, stopArea, isFirst); 535 isFirst = false; 536 } 537 isFirst = true; 538 OsmPrimitive firstPlatform = null; 539 for(OsmPrimitive platform : stopArea.platforms) 540 { 541 commands = platformTagAssign(platform, commands, stopArea, isFirst); 542 if(isFirst) 543 firstPlatform = platform; 544 isFirst = false; 545 } 546 if(needSeparateBusStop(stopArea, firstPlatform)) 547 { 548 if(stopArea.isBusStation) 549 { 550 if(separateBusStopNode == null) 551 { 552 commands = createSeparateBusStopNode(commands, stopArea, firstPlatform, OSMTags.AMENITY_TAG, OSMTags.BUS_STATION_TAG_VALUE); 553 } 554 else 555 { 556 commands = assignTag(commands, separateBusStopNode, OSMTags.AMENITY_TAG, OSMTags.BUS_STATION_TAG_VALUE); 557 } 558 } 559 else 560 { 561 if(separateBusStopNode == null) 562 { 563 commands = createSeparateBusStopNode(commands, stopArea, firstPlatform, OSMTags.HIGHWAY_TAG, OSMTags.BUS_STOP_TAG_VALUE); 564 } 565 else 566 { 567 commands = assignTag(commands, separateBusStopNode, OSMTags.HIGHWAY_TAG, OSMTags.BUS_STOP_TAG_VALUE); 568 } 569 } 570 } 571 else 572 { 573 if(stopArea.isBusStation) 574 { 575 commands = assignTag(commands, firstPlatform, OSMTags.AMENITY_TAG, OSMTags.BUS_STATION_TAG_VALUE); 576 } 577 else 578 if(stopArea.isBus || stopArea.isTrolleybus || stopArea.isShareTaxi) 579 { 580 commands = assignTag(commands, firstPlatform, OSMTags.HIGHWAY_TAG, OSMTags.BUS_STOP_TAG_VALUE); 581 } 582 } 583 for(OsmPrimitive otherMember : stopArea.otherMembers) 584 { 585 commands = otherMemberTagAssign(otherMember, commands, stopArea); 586 } 587 if(stopArea.stopAreaRelation == null) 588 { 589 if(stopArea.stopPoints.size() + stopArea.platforms.size() + stopArea.otherMembers.size() > 1) 590 { 591 commands = createStopAreaRelation(commands, stopArea); 592 } 593 } 594 else 595 { 596 commands = generalTagAssign(stopArea.stopAreaRelation, commands, stopArea); 597 commands = transportTypeTagClearing(stopArea.stopAreaRelation, commands); 598 commands = addNewRelationMembers(commands, stopArea); 599 } 600 return commands; 601 } 602 catch(Exception ex) 603 { 604 MessageBox.ok(ex.getMessage()); 605 } 606 return null; 607 } 608 609 /** 610 * Construct and executing command list for customizing of stop area relation and its members 611 * @param stopArea Stop area object 612 * @return Stop area object 613 */ 614 @Override 615 public StopArea performCustomizing(StopArea stopArea) 616 { 617 List<Command> commands = customize(stopArea); 618 if(commands != null && !commands.isEmpty()) 619 try 620 { 621 Main.main.undoRedo.add(new SequenceCommand(tr(TAG_ASSIGN_COMMAND_NAME), commands)); 622 return stopArea; 623 } 624 catch(Exception ex) 625 { 626 } 627 return stopArea; 628 } 259 * 260 * @param commands Original command list 261 * @param stopArea Stop area object 262 * @return Resulting command list 263 */ 264 private List<Command> createStopAreaRelation(List<Command> commands, StopArea stopArea) { 265 if (commands == null) 266 commands = new ArrayList<Command>(); 267 268 Relation newRelation = new Relation(); 269 for (Node node : stopArea.stopPoints) { 270 newRelation.addMember(new RelationMember(OSMTags.STOP_ROLE, node)); 271 } 272 for (OsmPrimitive platform : stopArea.platforms) { 273 newRelation.addMember(new RelationMember(OSMTags.PLATFORM_ROLE, platform)); 274 } 275 for (OsmPrimitive otherMember : stopArea.otherMembers) { 276 newRelation.addMember(new RelationMember("", otherMember)); 277 } 278 Main.main.undoRedo.add(new AddCommand(MainApplication.getLayerManager().getEditDataSet(), newRelation)); 279 commands = generalTagAssign(newRelation, commands, stopArea); 280 commands = assignTag(commands, newRelation, OSMTags.TYPE_TAG, OSMTags.PUBLIC_TRANSPORT_TAG); 281 commands = assignTag(commands, newRelation, OSMTags.PUBLIC_TRANSPORT_TAG, OSMTags.STOP_AREA_TAG_VALUE); 282 return commands; 283 } 284 285 /** 286 * Adding of new stop area members to relation 287 * 288 * @param commands Original command list 289 * @param targetRelation Stop area relation 290 * @param member Stop area relation member 291 * @param roleName Role name 292 * @return Resulting command list 293 */ 294 public static List<Command> addNewRelationMember(List<Command> commands, Relation targetRelation, 295 OsmPrimitive member, String roleName) { 296 if (commands == null) 297 commands = new ArrayList<Command>(); 298 299 for (RelationMember relationMember : targetRelation.getMembers()) { 300 if (relationMember.getMember() == member) { 301 if (relationMember.getRole() == roleName) { 302 return commands; 303 } 304 return commands; 305 } 306 } 307 targetRelation.addMember(new RelationMember(roleName, member)); 308 commands.add(new ChangeCommand(targetRelation, targetRelation)); 309 return commands; 310 } 311 312 /** 313 * Adding new stop area members to relation 314 * 315 * @param commands Original command list 316 * @param stopArea Stop area object 317 * @return Resulting command list 318 */ 319 private List<Command> addNewRelationMembers(List<Command> commands, StopArea stopArea) { 320 if (commands == null) 321 commands = new ArrayList<Command>(); 322 323 for (OsmPrimitive stopPoint : stopArea.stopPoints) { 324 commands = addNewRelationMember(commands, stopArea.stopAreaRelation, stopPoint, OSMTags.STOP_ROLE); 325 } 326 for (OsmPrimitive platform : stopArea.platforms) { 327 commands = addNewRelationMember(commands, stopArea.stopAreaRelation, platform, OSMTags.PLATFORM_ROLE); 328 } 329 for (OsmPrimitive otherMember : stopArea.otherMembers) { 330 commands = addNewRelationMember(commands, stopArea.stopAreaRelation, otherMember, null); 331 } 332 return commands; 333 } 334 335 /** 336 * Testing, is josm object bus stop node or contains bus stop node, defined by 337 * tag and its value 338 * 339 * @param member Josm object 340 * @param tag Tag name 341 * @param tagValue Tag value 342 * @return true, if josm object is bus stop node or contains bus stop node 343 */ 344 private Node searchBusStop(OsmPrimitive member, String tag, String tagValue) { 345 if (member instanceof Node) { 346 if (compareTag(member, tag, tagValue)) { 347 return (Node) member; 348 } 349 } else { 350 Way memberWay = (Way) member; 351 for (Node node : memberWay.getNodes()) { 352 if (compareTag(node, tag, tagValue)) { 353 return node; 354 } 355 } 356 } 357 return null; 358 } 359 360 /** 361 * Testing, do stop area contains bus stop node, defined by tag and its value 362 * 363 * @param tag Tag name 364 * @param tagValue Tag value 365 * @return true, if stop area contains bus stop node 366 */ 367 public Node searchBusStop(StopArea stopArea, String tag, String tagValue) { 368 for (OsmPrimitive platform : stopArea.platforms) { 369 Node busStopNode = searchBusStop(platform, tag, tagValue); 370 if (busStopNode != null) 371 return busStopNode; 372 } 373 for (OsmPrimitive otherMember : stopArea.otherMembers) { 374 Node busStopNode = searchBusStop(otherMember, tag, tagValue); 375 if (busStopNode != null) 376 return busStopNode; 377 } 378 return null; 379 } 380 381 /** 382 * Testing, must stop area to have separate bus stop node 383 * 384 * @param stopArea Stop area object 385 * @param firstPlatform First platform of stop area JOSM object 386 * @return True, stop area must to have separate bus stop node 387 */ 388 public boolean needSeparateBusStop(StopArea stopArea, OsmPrimitive firstPlatform) { 389 if (((stopArea.isBus || stopArea.isShareTaxi || stopArea.isTrolleybus) && (firstPlatform instanceof Way))) { 390 return true; 391 } 392 return false; 393 } 394 395 /** 396 * Clear excess tags from JOSM object and its nodes 397 * 398 * @param commands Original command list 399 * @param target JOSM object 400 * @param tag Tag name 401 * @param tagValue Tag value 402 * @return Resulting command list 403 */ 404 private List<Command> clearExcessTags(List<Command> commands, OsmPrimitive target, String tag, String tagValue) { 405 if (commands == null) 406 commands = new ArrayList<Command>(); 407 408 if (compareTag(target, tag, tagValue)) { 409 commands = clearTag(commands, target, tag); 410 } 411 if (target instanceof Way) { 412 Way memberWay = (Way) target; 413 for (Node node : memberWay.getNodes()) { 414 if (compareTag(node, tag, tagValue)) { 415 commands = clearTag(commands, target, tag); 416 } 417 } 418 } 419 return commands; 420 } 421 422 /** 423 * Clear excess tags from JOSM object and its nodes 424 * 425 * @param commands Command list 426 * @param stopArea Stop area object 427 * @param tag Tag name 428 * @param tagValue Tag value 429 * @return Resulting command list 430 */ 431 public List<Command> clearExcessTags(List<Command> commands, StopArea stopArea, String tag, String tagValue) { 432 if (commands == null) 433 commands = new ArrayList<Command>(); 434 435 for (OsmPrimitive stopPoint : stopArea.stopPoints) { 436 clearExcessTags(commands, stopPoint, tag, tagValue); 437 } 438 for (OsmPrimitive platform : stopArea.platforms) { 439 clearExcessTags(commands, platform, tag, tagValue); 440 } 441 for (OsmPrimitive otherMember : stopArea.otherMembers) { 442 clearExcessTags(commands, otherMember, tag, tagValue); 443 } 444 return commands; 445 } 446 447 /** 448 * Create separate bus stop node or assign bus stop tag to platform node 449 * 450 * @param commands Original command list 451 * @param stopArea Stop area object 452 * @param firstPlatform First platform in stop area relation 453 * @param tag Tag name 454 * @param tagValue Tag value 455 * @return Resulting command list 456 */ 457 protected List<Command> createSeparateBusStopNode(List<Command> commands, StopArea stopArea, 458 OsmPrimitive firstPlatform, String tag, String tagValue) { 459 if (commands == null) 460 commands = new ArrayList<Command>(); 461 462 LatLon centerOfPlatform = getCenterOfWay(firstPlatform); 463 if (firstPlatform instanceof Way) { 464 if (centerOfPlatform != null) { 465 Node newNode = new Node(); 466 newNode.setCoor(centerOfPlatform); 467 Main.main.undoRedo.add(new AddCommand(MainApplication.getLayerManager().getEditDataSet(), newNode)); 468 Main.main.undoRedo.add(new ChangePropertyCommand(newNode, tag, tagValue)); 469 commands = assignTag(commands, newNode, tag, tagValue); 470 stopArea.otherMembers.add(newNode); 471 } 472 } else { 473 commands = assignTag(commands, firstPlatform, tag, tagValue); 474 } 475 return commands; 476 } 477 478 /** 479 * Forming commands for JOSM for saving stop area members and relation 480 * attributes 481 * 482 * @param stopArea Stop area object 483 * @return Resulting command list 484 */ 485 public List<Command> customize(StopArea stopArea) { 486 try { 487 List<Command> commands = new ArrayList<Command>(); 488 Node separateBusStopNode = searchBusStop(stopArea, OSMTags.AMENITY_TAG, OSMTags.BUS_STATION_TAG_VALUE); 489 if (separateBusStopNode == null) 490 separateBusStopNode = searchBusStop(stopArea, OSMTags.HIGHWAY_TAG, OSMTags.BUS_STOP_TAG_VALUE); 491 if (stopArea.isBusStation) { 492 commands = clearExcessTags(commands, stopArea, OSMTags.HIGHWAY_TAG, OSMTags.BUS_STOP_TAG_VALUE); 493 } else { 494 commands = clearExcessTags(commands, stopArea, OSMTags.AMENITY_TAG, OSMTags.BUS_STATION_TAG_VALUE); 495 } 496 if (!(stopArea.isBus || stopArea.isShareTaxi || stopArea.isTrolleybus)) { 497 commands = clearExcessTags(commands, stopArea, OSMTags.HIGHWAY_TAG, OSMTags.BUS_STOP_TAG_VALUE); 498 } 499 if (stopArea.stopPoints.size() == 0) { 500 CreateNewStopPointOperation createNewStopPointOperation = new CreateNewStopPointOperation( 501 getCurrentDataSet()); 502 createNewStopPointOperation.performCustomizing(stopArea); 503 } 504 Boolean isFirst = true; 505 for (Node node : stopArea.stopPoints) { 506 commands = stopPointTagAssign(node, commands, stopArea, isFirst); 507 isFirst = false; 508 } 509 isFirst = true; 510 OsmPrimitive firstPlatform = null; 511 for (OsmPrimitive platform : stopArea.platforms) { 512 commands = platformTagAssign(platform, commands, stopArea, isFirst); 513 if (isFirst) 514 firstPlatform = platform; 515 isFirst = false; 516 } 517 if (needSeparateBusStop(stopArea, firstPlatform)) { 518 if (stopArea.isBusStation) { 519 if (separateBusStopNode == null) { 520 commands = createSeparateBusStopNode(commands, stopArea, firstPlatform, OSMTags.AMENITY_TAG, 521 OSMTags.BUS_STATION_TAG_VALUE); 522 } else { 523 commands = assignTag(commands, separateBusStopNode, OSMTags.AMENITY_TAG, 524 OSMTags.BUS_STATION_TAG_VALUE); 525 } 526 } else { 527 if (separateBusStopNode == null) { 528 commands = createSeparateBusStopNode(commands, stopArea, firstPlatform, OSMTags.HIGHWAY_TAG, 529 OSMTags.BUS_STOP_TAG_VALUE); 530 } else { 531 commands = assignTag(commands, separateBusStopNode, OSMTags.HIGHWAY_TAG, 532 OSMTags.BUS_STOP_TAG_VALUE); 533 } 534 } 535 } else { 536 if (stopArea.isBusStation) { 537 commands = assignTag(commands, firstPlatform, OSMTags.AMENITY_TAG, OSMTags.BUS_STATION_TAG_VALUE); 538 } else if (stopArea.isBus || stopArea.isTrolleybus || stopArea.isShareTaxi) { 539 commands = assignTag(commands, firstPlatform, OSMTags.HIGHWAY_TAG, OSMTags.BUS_STOP_TAG_VALUE); 540 } 541 } 542 for (OsmPrimitive otherMember : stopArea.otherMembers) { 543 commands = otherMemberTagAssign(otherMember, commands, stopArea); 544 } 545 if (stopArea.stopAreaRelation == null) { 546 if (stopArea.stopPoints.size() + stopArea.platforms.size() + stopArea.otherMembers.size() > 1) { 547 commands = createStopAreaRelation(commands, stopArea); 548 } 549 } else { 550 commands = generalTagAssign(stopArea.stopAreaRelation, commands, stopArea); 551 commands = transportTypeTagClearing(stopArea.stopAreaRelation, commands); 552 commands = addNewRelationMembers(commands, stopArea); 553 } 554 return commands; 555 } catch (Exception ex) { 556 MessageBox.ok(ex.getMessage()); 557 } 558 return null; 559 } 560 561 /** 562 * Construct and executing command list for customizing of stop area relation 563 * and its members 564 * 565 * @param stopArea Stop area object 566 * @return Stop area object 567 */ 568 @Override 569 public StopArea performCustomizing(StopArea stopArea) { 570 List<Command> commands = customize(stopArea); 571 if (commands != null && !commands.isEmpty()) 572 try { 573 Main.main.undoRedo.add(new SequenceCommand(tr(TAG_ASSIGN_COMMAND_NAME), commands)); 574 return stopArea; 575 } catch (Exception ex) { 576 Logging.error(ex); 577 } 578 return stopArea; 579 } 629 580 630 581 } -
applications/editors/josm/plugins/CustomizePublicTransportStop/src/ru/rodsoft/openstreetmap/josm/plugins/customizepublictransportstop/IStopAreaCustomizer.java
r32048 r34156 1 // License: GPL. For details, see LICENSE file. 1 2 package ru.rodsoft.openstreetmap.josm.plugins.customizepublictransportstop; 2 3 3 4 /** 5 * Interface of operation of stop area customizing 4 6 * 5 7 * @author Rodion Scherbakov 6 * Interface of operation of stop area customizing7 8 */ 8 public interface IStopAreaCustomizer 9 { 10 /** 11 * Perform operation of customizing of stop area 12 13 14 15 publicStopArea performCustomizing(StopArea stopArea);9 public interface IStopAreaCustomizer { 10 /** 11 * Perform operation of customizing of stop area 12 * 13 * @param stopArea Stop area 14 * @return Stop area after customizing 15 */ 16 StopArea performCustomizing(StopArea stopArea); 16 17 } -
applications/editors/josm/plugins/CustomizePublicTransportStop/src/ru/rodsoft/openstreetmap/josm/plugins/customizepublictransportstop/MessageBox.java
r32048 r34156 1 // License: GPL. For details, see LICENSE file. 1 2 package ru.rodsoft.openstreetmap.josm.plugins.customizepublictransportstop; 3 2 4 import javax.swing.JOptionPane; 3 5 import java.awt.Component; 4 /** 6 7 /** 8 * MessageBox static class It is used for debug. Source: Java forums 9 * <a>http://www.java-forums.org/java-tip/6578-messagebox-example.html</a> 5 10 * 6 11 * @author Moderator 7 * MessageBox static class8 * It is used for debug9 * Source: Java forums <a>http://www.java-forums.org/java-tip/6578-messagebox-example.html</a>10 12 */ 11 public class MessageBox { 12 /* 13 These are a list of STATIC MODAL dialogs 14 15 int return codes of button pressed: 16 17 -1 - WINDOW CLOSED - the X PRESSED 18 0 - YES and OK 19 1 - NO 20 2 - CANCEL 21 22 (thanks to flipside for the idea) 23 */ 24 25 /** 26 * Show message box with "yes" and "no" buttons 27 * @param theMessage Message for user 28 * @return Code of pressed button 29 */ 30 public static int yesno(String theMessage){ 31 int result = JOptionPane.showConfirmDialog((Component) 32 null, theMessage, "alert", JOptionPane.YES_NO_OPTION); 33 return result; 34 } 35 36 /** 37 * Show message box with "yes", "no" and "cancel" buttons 38 * @param theMessage Message for user 39 * @return Code of pressed button 40 */ 41 public static int yesnocancel(String theMessage){ 42 int result = JOptionPane.showConfirmDialog((Component) 43 null, theMessage, "alert", JOptionPane.YES_NO_CANCEL_OPTION); 44 return result; 45 } 46 47 /** 48 * Show message box with "Ok" and "Cancel" buttons 49 * @param theMessage Message for user 50 * @return Code of pressed button 51 */ 52 public static int okcancel(String theMessage){ 53 int result = JOptionPane.showConfirmDialog((Component) 54 null, theMessage, "alert", JOptionPane.OK_CANCEL_OPTION); 55 return result; 56 } 57 58 /** 59 * Show message box with "ok" button 60 * @param theMessage Message for user 61 * @return Code of pressed button 62 */ 63 public static int ok(String theMessage){ 64 int result = JOptionPane.showConfirmDialog((Component) 65 null, theMessage, "alert", JOptionPane.DEFAULT_OPTION); 66 return result; 67 } 68 69 /** 70 * Main method for test launch 71 * 72 * @param args Arguments of command line 73 */ 74 public static void main(String args[]){ 75 int i = MessageBox.yesno("Are your sure ?"); 76 System.out.println("ret : " + i ); 77 i = MessageBox.yesnocancel("Are your sure ?"); 78 System.out.println("ret : " + i ); 79 i = MessageBox.okcancel("Are your sure ?"); 80 System.out.println("ret : " + i ); 81 i = MessageBox.ok("Done."); 82 System.out.println("ret : " + i ); 83 } 13 public final class MessageBox { 14 /* 15 * These are a list of STATIC MODAL dialogs 16 * 17 * int return codes of button pressed: 18 * 19 * -1 - WINDOW CLOSED - the X PRESSED 0 - YES and OK 1 - NO 2 - CANCEL 20 * 21 * (thanks to flipside for the idea) 22 */ 23 24 /** 25 * Show message box with "yes" and "no" buttons 26 * 27 * @param theMessage Message for user 28 * @return Code of pressed button 29 */ 30 public static int yesno(String theMessage) { 31 int result = JOptionPane.showConfirmDialog((Component) null, theMessage, "alert", JOptionPane.YES_NO_OPTION); 32 return result; 33 } 34 35 /** 36 * Show message box with "yes", "no" and "cancel" buttons 37 * 38 * @param theMessage Message for user 39 * @return Code of pressed button 40 */ 41 public static int yesnocancel(String theMessage) { 42 int result = JOptionPane.showConfirmDialog((Component) null, theMessage, "alert", 43 JOptionPane.YES_NO_CANCEL_OPTION); 44 return result; 45 } 46 47 /** 48 * Show message box with "Ok" and "Cancel" buttons 49 * 50 * @param theMessage Message for user 51 * @return Code of pressed button 52 */ 53 public static int okcancel(String theMessage) { 54 int result = JOptionPane.showConfirmDialog((Component) null, theMessage, "alert", JOptionPane.OK_CANCEL_OPTION); 55 return result; 56 } 57 58 /** 59 * Show message box with "ok" button 60 * 61 * @param theMessage Message for user 62 * @return Code of pressed button 63 */ 64 public static int ok(String theMessage) { 65 int result = JOptionPane.showConfirmDialog((Component) null, theMessage, "alert", JOptionPane.DEFAULT_OPTION); 66 return result; 67 } 68 69 /** 70 * Main method for test launch 71 * 72 * @param args Arguments of command line 73 */ 74 public static void main(String[] args) { 75 int i = MessageBox.yesno("Are your sure ?"); 76 System.out.println("ret : " + i); 77 i = MessageBox.yesnocancel("Are your sure ?"); 78 System.out.println("ret : " + i); 79 i = MessageBox.okcancel("Are your sure ?"); 80 System.out.println("ret : " + i); 81 i = MessageBox.ok("Done."); 82 System.out.println("ret : " + i); 83 } 84 85 private MessageBox() { 86 // Hide default constructor 87 } 84 88 } -
applications/editors/josm/plugins/CustomizePublicTransportStop/src/ru/rodsoft/openstreetmap/josm/plugins/customizepublictransportstop/NearestWaySegment.java
r32048 r34156 1 // License: GPL. For details, see LICENSE file. 1 2 package ru.rodsoft.openstreetmap.josm.plugins.customizepublictransportstop; 2 3 … … 5 6 6 7 /** 8 * Distance from platform to ways 7 9 * 8 10 * @author Rodion Scherbakov 9 * Distance from platform to ways10 11 */ 11 public class NearestWaySegment 12 { 13 /** 14 * Square of distance 15 */ 16 public Double distanceSq = 1000000000.0; 17 /** 18 * Way segment 19 */ 20 public WaySegment waySegment; 21 /** 22 * Node 23 */ 24 public Node newNode; 25 26 /** 27 * Constructor 28 * @param distanceSq Square of distance 29 * @param waySegment Way segment 30 * @param newNode Node 31 */ 32 public NearestWaySegment(Double distanceSq, WaySegment waySegment, Node newNode) 33 { 34 this.distanceSq = distanceSq; 35 this.waySegment = waySegment; 36 this.newNode = newNode; 37 } 12 public class NearestWaySegment { 13 /** 14 * Square of distance 15 */ 16 public Double distanceSq = 1000000000.0; 17 /** 18 * Way segment 19 */ 20 public WaySegment waySegment; 21 /** 22 * Node 23 */ 24 public Node newNode; 25 26 /** 27 * Constructor 28 * 29 * @param distanceSq Square of distance 30 * @param waySegment Way segment 31 * @param newNode Node 32 */ 33 public NearestWaySegment(Double distanceSq, WaySegment waySegment, Node newNode) { 34 this.distanceSq = distanceSq; 35 this.waySegment = waySegment; 36 this.newNode = newNode; 37 } 38 38 } -
applications/editors/josm/plugins/CustomizePublicTransportStop/src/ru/rodsoft/openstreetmap/josm/plugins/customizepublictransportstop/OSMTags.java
r32840 r34156 1 // License: GPL. For details, see LICENSE file. 1 2 package ru.rodsoft.openstreetmap.josm.plugins.customizepublictransportstop; 2 3 3 4 /** 5 * OSM object tags 4 6 * 5 7 * @author Rodion Scherbakov 6 * OSM object tags7 8 */ 8 public class OSMTags 9 { 10 public static final String TERTIARY_LINK_TAG_VALUE = "tertiary_link"; 11 public static final String SECONDARY_LINK_TAG_VALUE = "secondary_link"; 12 public static final String PRIMARY_LINK_TAG_VALUE = "primary_link"; 13 public static final String TRUNK_LINK_TAG_VALUE = "trunk_link"; 14 public static final String ROAD_TAG_VALUE = "road"; 15 public static final String BUS_GUIDEWAY_TAG_VALUE = "bus_guideway"; 16 public static final String SERVICE_TAG_VALUE = "service"; 17 public static final String RESIDENTIAL_TAG_VALUE = "residential"; 18 public static final String UNCLASSIFIED_TAG_VALUE = "unclassified"; 19 public static final String TERTIARY_TAG_VALUE = "tertiary"; 20 public static final String SECONDARY_TAG_VALUE = "secondary"; 21 public static final String PRIMARY_TAG_VALUE = "primary"; 22 public static final String TRUNK_TAG_VALUE = "trunk"; 23 public static final String TRAM_TAG_VALUE = "tram"; 24 public static final String USAGE_TAG = "usage"; 25 public static final String MAIN_TAG_VALUE = "main"; 26 public static final String RAIL_TAG_VALUE = "rail"; 9 public final class OSMTags { 10 public static final String TERTIARY_LINK_TAG_VALUE = "tertiary_link"; 11 public static final String SECONDARY_LINK_TAG_VALUE = "secondary_link"; 12 public static final String PRIMARY_LINK_TAG_VALUE = "primary_link"; 13 public static final String TRUNK_LINK_TAG_VALUE = "trunk_link"; 14 public static final String ROAD_TAG_VALUE = "road"; 15 public static final String BUS_GUIDEWAY_TAG_VALUE = "bus_guideway"; 16 public static final String SERVICE_TAG_VALUE = "service"; 17 public static final String RESIDENTIAL_TAG_VALUE = "residential"; 18 public static final String UNCLASSIFIED_TAG_VALUE = "unclassified"; 19 public static final String TERTIARY_TAG_VALUE = "tertiary"; 20 public static final String SECONDARY_TAG_VALUE = "secondary"; 21 public static final String PRIMARY_TAG_VALUE = "primary"; 22 public static final String TRUNK_TAG_VALUE = "trunk"; 23 public static final String TRAM_TAG_VALUE = "tram"; 24 public static final String USAGE_TAG = "usage"; 25 public static final String MAIN_TAG_VALUE = "main"; 26 public static final String RAIL_TAG_VALUE = "rail"; 27 27 28 public static final String AREA_TAG = "area"; 29 public static final String COVERED_TAG = "covered"; 30 public static final String SHELTER_TAG = "shelter"; 31 public static final String BENCH_TAG = "bench"; 32 public static final String TRAIN_TAG = "train"; 33 public static final String STOP_POSITION_TAG_VALUE = "stop_position"; 34 public static final String STATION_TAG_VALUE = "station"; 35 public static final String HALT_TAG_VALUE = "halt"; 36 public static final String YES_TAG_VALUE = "yes"; 37 public static final String RAILWAY_TAG = "railway"; 38 public static final String TRAM_STOP_TAG_VALUE = "tram_stop"; 39 public static final String TRAM_TAG = "tram"; 40 public static final String SHARE_TAXI_TAG = "share_taxi"; 41 public static final String TROLLEYBUS_TAG = "trolleybus"; 42 public static final String BUS_TAG = "bus"; 43 public static final String NETWORK_TAG = "network"; 44 public static final String OPERATOR_TAG = "operator"; 45 public static final String NAME_EN_TAG = "name:en"; 46 public static final String NAME_TAG = "name"; 47 public static final String HIGHWAY_TAG = "highway"; 48 public static final String AMENITY_TAG = "amenity"; 49 public static final String BUS_STATION_TAG_VALUE = "bus_station"; 50 51 public static final String BUS_STOP_TAG_VALUE = "bus_stop"; 52 public static final String TYPE_TAG = "type"; 53 public static final String PUBLIC_TRANSPORT_TAG = "public_transport"; 54 public static final String STOP_AREA_TAG_VALUE = "stop_area"; 55 public static final String STOP_ROLE = "stop"; 56 public static final String PLATFORM_ROLE = "platform"; 57 public static final String PLATFORM_TAG_VALUE = "platform"; 58 public static final String SERVICE_TAG = "service"; 28 public static final String AREA_TAG = "area"; 29 public static final String COVERED_TAG = "covered"; 30 public static final String SHELTER_TAG = "shelter"; 31 public static final String BENCH_TAG = "bench"; 32 public static final String TRAIN_TAG = "train"; 33 public static final String STOP_POSITION_TAG_VALUE = "stop_position"; 34 public static final String STATION_TAG_VALUE = "station"; 35 public static final String HALT_TAG_VALUE = "halt"; 36 public static final String YES_TAG_VALUE = "yes"; 37 public static final String RAILWAY_TAG = "railway"; 38 public static final String TRAM_STOP_TAG_VALUE = "tram_stop"; 39 public static final String TRAM_TAG = "tram"; 40 public static final String SHARE_TAXI_TAG = "share_taxi"; 41 public static final String TROLLEYBUS_TAG = "trolleybus"; 42 public static final String BUS_TAG = "bus"; 43 public static final String NETWORK_TAG = "network"; 44 public static final String OPERATOR_TAG = "operator"; 45 public static final String NAME_EN_TAG = "name:en"; 46 public static final String NAME_TAG = "name"; 47 public static final String HIGHWAY_TAG = "highway"; 48 public static final String AMENITY_TAG = "amenity"; 49 public static final String BUS_STATION_TAG_VALUE = "bus_station"; 59 50 60 public static final String CITY_NETWORK_TAG_VALUE = "city"; 61 public static final String COMMUTER_NETWORK_TAG_VALUE = "commuter"; 62 public static final String LOCAL_NETWORK_TAG_VALUE = "local"; 63 public static final String REGIONAL_NETWORK_TAG_VALUE = "regional"; 51 public static final String BUS_STOP_TAG_VALUE = "bus_stop"; 52 public static final String TYPE_TAG = "type"; 53 public static final String PUBLIC_TRANSPORT_TAG = "public_transport"; 54 public static final String STOP_AREA_TAG_VALUE = "stop_area"; 55 public static final String STOP_ROLE = "stop"; 56 public static final String PLATFORM_ROLE = "platform"; 57 public static final String PLATFORM_TAG_VALUE = "platform"; 58 public static final String SERVICE_TAG = "service"; 59 60 public static final String CITY_NETWORK_TAG_VALUE = "city"; 61 public static final String COMMUTER_NETWORK_TAG_VALUE = "commuter"; 62 public static final String LOCAL_NETWORK_TAG_VALUE = "local"; 63 public static final String REGIONAL_NETWORK_TAG_VALUE = "regional"; 64 64 public static final String LONG_DISTANCE_NETWORK_TAG_VALUE = "long_distance"; 65 65 public static final String HIGH_SPEED_NETWORK_TAG_VALUE = "high_speed"; 66 66 67 private OSMTags() { 68 // Hide default constructor 69 } 67 70 } -
applications/editors/josm/plugins/CustomizePublicTransportStop/src/ru/rodsoft/openstreetmap/josm/plugins/customizepublictransportstop/StopArea.java
r32048 r34156 1 // License: GPL. For details, see LICENSE file. 1 2 package ru.rodsoft.openstreetmap.josm.plugins.customizepublictransportstop; 2 3 … … 9 10 10 11 /** 12 * Stop area settings 11 13 * 12 14 * @author Rodion Scherbakov 13 * Stop area settings14 15 */ 15 16 public class StopArea { 16 17 17 /** 18 * Name of stop area 19 */ 20 public String name = null; 21 /** 22 * English name of stop area 23 */ 24 public String nameEn = null; 25 /** 26 * Operator of stop area 27 */ 28 public String operator = null; 29 /** 30 * Network name 31 */ 32 public String network = null; 33 /** 34 * Level of network including this stop area 35 */ 36 public String service = null; 37 /** 38 * Flag of bus stop area 39 */ 40 public Boolean isBus = false; 41 /** 42 * Flag of trolleybus stop area 43 */ 44 public Boolean isTrolleybus = false; 45 /** 46 * Flag of share taxi stop area 47 */ 48 public Boolean isShareTaxi = false; 49 /** 50 * Flag of bus station stop area 51 */ 52 public Boolean isBusStation = false; 53 /** 54 * Flag of tram stop area 55 */ 56 public Boolean isTram = false; 57 /** 58 * Flag of railway stop area 59 */ 60 public Boolean isTrainStop = false; 61 /** 62 * Flag of railway station 63 */ 64 public Boolean isTrainStation = false; 65 /** 66 * Flag of bench on selected platform 67 */ 68 public Boolean isAssignTransportType = false; 69 /** 70 * Flag of bench near platform 71 */ 72 public Boolean isBench = false; 73 /** 74 * Flag of covered platform 75 */ 76 public Boolean isCovered = false; 77 /** 78 * Flag of shelter on selected platform 79 */ 80 public Boolean isShelter = false; 81 /** 82 * Relation of stop area 83 */ 84 public Relation stopAreaRelation = null; 85 /** 86 * Flag of existing of stop position 87 */ 88 public Boolean isStopPointExists = false; 89 /** 90 * Flag of area platform 91 */ 92 public Boolean isArea = false; 93 /** 94 * Separate node of bus stop or bus station 95 */ 96 public Node separateBusStopNode = null; 97 98 /** 99 * List of nodes of stop positions 100 */ 101 public final ArrayList<Node> stopPoints = new ArrayList<Node>(); 102 /** 103 * List of josm objects of platforms 104 */ 105 public final ArrayList<OsmPrimitive> platforms = new ArrayList<OsmPrimitive>(); 106 /** 107 * List of non stop positions or platform stop area members 108 */ 109 public final ArrayList<OsmPrimitive> otherMembers = new ArrayList<OsmPrimitive>(); 110 111 /** 112 * Selected josm objects. Must be a platform 113 */ 114 public OsmPrimitive selectedObject = null; 18 /** 19 * Name of stop area 20 */ 21 public String name = null; 22 /** 23 * English name of stop area 24 */ 25 public String nameEn = null; 26 /** 27 * Operator of stop area 28 */ 29 public String operator = null; 30 /** 31 * Network name 32 */ 33 public String network = null; 34 /** 35 * Level of network including this stop area 36 */ 37 public String service = null; 38 /** 39 * Flag of bus stop area 40 */ 41 public Boolean isBus = false; 42 /** 43 * Flag of trolleybus stop area 44 */ 45 public Boolean isTrolleybus = false; 46 /** 47 * Flag of share taxi stop area 48 */ 49 public Boolean isShareTaxi = false; 50 /** 51 * Flag of bus station stop area 52 */ 53 public Boolean isBusStation = false; 54 /** 55 * Flag of tram stop area 56 */ 57 public Boolean isTram = false; 58 /** 59 * Flag of railway stop area 60 */ 61 public Boolean isTrainStop = false; 62 /** 63 * Flag of railway station 64 */ 65 public Boolean isTrainStation = false; 66 /** 67 * Flag of bench on selected platform 68 */ 69 public Boolean isAssignTransportType = false; 70 /** 71 * Flag of bench near platform 72 */ 73 public Boolean isBench = false; 74 /** 75 * Flag of covered platform 76 */ 77 public Boolean isCovered = false; 78 /** 79 * Flag of shelter on selected platform 80 */ 81 public Boolean isShelter = false; 82 /** 83 * Relation of stop area 84 */ 85 public Relation stopAreaRelation = null; 86 /** 87 * Flag of existing of stop position 88 */ 89 public Boolean isStopPointExists = false; 90 /** 91 * Flag of area platform 92 */ 93 public Boolean isArea = false; 94 /** 95 * Separate node of bus stop or bus station 96 */ 97 public Node separateBusStopNode = null; 115 98 116 117 /** 118 * Constructor of stop area object 119 */ 120 public StopArea() 121 { } 122 123 /** 124 * Constructor of stop area object from selected object 125 * @param selectedObject Selected object 126 */ 127 public StopArea(OsmPrimitive selectedObject) 128 { 129 this.selectedObject = selectedObject; 130 } 131 132 /** 133 * Get selected in editor node 134 * @return Selected node or null 135 */ 136 public Node getSelectedNode() 137 { 138 if(selectedObject instanceof Node) 139 return (Node)selectedObject; 140 return null; 141 } 142 143 /** 144 * Get selected way 145 * @return Selected way or null 146 */ 147 public Way getSelectedWay() 148 { 149 if(selectedObject instanceof Way) 150 return (Way)selectedObject; 151 return null; 152 } 153 99 /** 100 * List of nodes of stop positions 101 */ 102 public final ArrayList<Node> stopPoints = new ArrayList<Node>(); 103 /** 104 * List of josm objects of platforms 105 */ 106 public final ArrayList<OsmPrimitive> platforms = new ArrayList<OsmPrimitive>(); 107 /** 108 * List of non stop positions or platform stop area members 109 */ 110 public final ArrayList<OsmPrimitive> otherMembers = new ArrayList<OsmPrimitive>(); 111 112 /** 113 * Selected josm objects. Must be a platform 114 */ 115 public OsmPrimitive selectedObject = null; 116 117 /** 118 * Constructor of stop area object 119 */ 120 public StopArea() { 121 } 122 123 /** 124 * Constructor of stop area object from selected object 125 * 126 * @param selectedObject Selected object 127 */ 128 public StopArea(OsmPrimitive selectedObject) { 129 this.selectedObject = selectedObject; 130 } 131 132 /** 133 * Get selected in editor node 134 * 135 * @return Selected node or null 136 */ 137 public Node getSelectedNode() { 138 if (selectedObject instanceof Node) 139 return (Node) selectedObject; 140 return null; 141 } 142 143 /** 144 * Get selected way 145 * 146 * @return Selected way or null 147 */ 148 public Way getSelectedWay() { 149 if (selectedObject instanceof Way) 150 return (Way) selectedObject; 151 return null; 152 } 154 153 } -
applications/editors/josm/plugins/CustomizePublicTransportStop/src/ru/rodsoft/openstreetmap/josm/plugins/customizepublictransportstop/StopAreaOperationBase.java
r32048 r34156 1 // License: GPL. For details, see LICENSE file. 1 2 package ru.rodsoft.openstreetmap.josm.plugins.customizepublictransportstop; 2 3 … … 13 14 14 15 /** 16 * Base class of operation of customizing of stop area 17 * 15 18 * @author Rodion Scherbakov 16 * Base class of operation of customizing of stop area17 19 */ 18 public abstract class StopAreaOperationBase implements IStopAreaCustomizer 19 { 20 public abstract class StopAreaOperationBase implements IStopAreaCustomizer { 20 21 21 /** 22 * Current dataset of Josm 23 */ 24 private DataSet _CurrentDataSet; 25 26 /** 27 * Constructor of operation of customizing of stop area 28 * @param currentDataSet Current data set of JOSM 29 */ 30 public StopAreaOperationBase(DataSet currentDataSet) 31 { 32 _CurrentDataSet = currentDataSet; 33 } 22 /** 23 * Current dataset of Josm 24 */ 25 private DataSet _CurrentDataSet; 34 26 35 /** 36 * Get current dataset of Josm 37 * Used for comparability wit previous version 38 * @return Current dataset of Josm 39 */ 40 protected DataSet getCurrentDataSet() 41 { 42 return _CurrentDataSet; 43 } 44 45 /** 46 * Perform operation of customizing of stop area 47 * @param stopArea Stop area object 48 * @return stopArea Resulting stop area object 49 */ 50 @Override 51 public abstract StopArea performCustomizing(StopArea stopArea); 27 /** 28 * Constructor of operation of customizing of stop area 29 * 30 * @param currentDataSet Current data set of JOSM 31 */ 32 public StopAreaOperationBase(DataSet currentDataSet) { 33 _CurrentDataSet = currentDataSet; 34 } 52 35 53 /** 54 * Get tag value of JOSM object 55 * @param member JOSM object 56 * @param tagName Tag name 57 * @return Tag value 58 */ 59 public static String getTagValue(OsmPrimitive member, String tagName) 60 { 61 return member.getKeys().get(tagName); 62 } 63 64 /** 65 * Comparing of value of tag for josm object 66 * @param osmObject JOSM object 67 * @param tagName Tag name 68 * @param tagValue Tag value 69 * @return true, if tag exists and equals tagValue 70 */ 71 public static Boolean compareTag (OsmPrimitive osmObject, String tagName, String tagValue) 72 { 73 String value = osmObject.getKeys().get(tagName); 74 if(value != null) 75 return value.equals(tagValue); 76 return false; 77 } 78 79 /** 80 * Assign tag value to JOSM object 81 * @param commands Command list 82 * @param target Target OSM object 83 * @param tag Tag name 84 * @param tagValue Tag value 85 * @return Resulting command list 86 */ 87 public static List<Command> assignTag(List<Command> commands, OsmPrimitive target, String tag, String tagValue) 88 { 89 if(commands == null) 90 commands = new ArrayList<Command>(); 91 commands.add(new ChangePropertyCommand(target, tag, tagValue)); 92 return commands; 93 } 94 95 /** 96 * Clear tag value of JOSM object 97 * @param commands Command list 98 * @param target Target OSM object 99 * @param tag Tag name 100 * @return Resulting command list 101 */ 102 public static List<Command> clearTag(List<Command> commands, OsmPrimitive target, String tag) 103 { 104 return assignTag(commands, target, tag, null); 105 } 106 36 /** 37 * Get current dataset of Josm Used for comparability wit previous version 38 * 39 * @return Current dataset of Josm 40 */ 41 protected DataSet getCurrentDataSet() { 42 return _CurrentDataSet; 43 } 44 45 /** 46 * Perform operation of customizing of stop area 47 * 48 * @param stopArea Stop area object 49 * @return stopArea Resulting stop area object 50 */ 51 @Override 52 public abstract StopArea performCustomizing(StopArea stopArea); 53 54 /** 55 * Get tag value of JOSM object 56 * 57 * @param member JOSM object 58 * @param tagName Tag name 59 * @return Tag value 60 */ 61 public static String getTagValue(OsmPrimitive member, String tagName) { 62 return member.getKeys().get(tagName); 63 } 64 65 /** 66 * Comparing of value of tag for josm object 67 * 68 * @param osmObject JOSM object 69 * @param tagName Tag name 70 * @param tagValue Tag value 71 * @return true, if tag exists and equals tagValue 72 */ 73 public static Boolean compareTag(OsmPrimitive osmObject, String tagName, String tagValue) { 74 String value = osmObject.getKeys().get(tagName); 75 if (value != null) 76 return value.equals(tagValue); 77 return false; 78 } 79 80 /** 81 * Assign tag value to JOSM object 82 * 83 * @param commands Command list 84 * @param target Target OSM object 85 * @param tag Tag name 86 * @param tagValue Tag value 87 * @return Resulting command list 88 */ 89 public static List<Command> assignTag(List<Command> commands, OsmPrimitive target, String tag, String tagValue) { 90 if (commands == null) 91 commands = new ArrayList<Command>(); 92 commands.add(new ChangePropertyCommand(target, tag, tagValue)); 93 return commands; 94 } 95 96 /** 97 * Clear tag value of JOSM object 98 * 99 * @param commands Command list 100 * @param target Target OSM object 101 * @param tag Tag name 102 * @return Resulting command list 103 */ 104 public static List<Command> clearTag(List<Command> commands, OsmPrimitive target, String tag) { 105 return assignTag(commands, target, tag, null); 106 } 107 107 108 /** 108 109 * Calculation of center of platform, if platform is way 110 * 109 111 * @param platform Platform primitive 110 112 * @return Coordinates of center of platform 111 113 */ 112 public static LatLon getCenterOfWay(OsmPrimitive platform) 113 { 114 if(platform instanceof Way) 115 { 116 //p = mapView.getPoint((Node) stopArea.selectedObject); 117 Double sumLat = 0.0; 118 Double sumLon = 0.0; 119 Integer countNode = 0; 120 for(Node node : ((Way) platform).getNodes()) 121 { 122 LatLon coord = node.getCoor(); 123 sumLat += coord.getX(); 124 sumLon += coord.getY(); 125 countNode++; 126 } 127 return new LatLon(sumLon / countNode, sumLat / countNode); 128 } 129 return null; 114 public static LatLon getCenterOfWay(OsmPrimitive platform) { 115 if (platform instanceof Way) { 116 // p = mapView.getPoint((Node) stopArea.selectedObject); 117 Double sumLat = 0.0; 118 Double sumLon = 0.0; 119 Integer countNode = 0; 120 for (Node node : ((Way) platform).getNodes()) { 121 LatLon coord = node.getCoor(); 122 sumLat += coord.getX(); 123 sumLon += coord.getY(); 124 countNode++; 125 } 126 return new LatLon(sumLon / countNode, sumLat / countNode); 127 } 128 return null; 130 129 } 131 130 132 133 131 }
Note:
See TracChangeset
for help on using the changeset viewer.