aboutsummaryrefslogtreecommitdiffstats
path: root/ardor3d-awt
diff options
context:
space:
mode:
authorneothemachine <[email protected]>2012-12-05 19:19:31 +0100
committerneothemachine <[email protected]>2012-12-05 19:19:31 +0100
commit7ca002eb1d1510767cd524a800710cf3898ba699 (patch)
tree7b3bd1dec9f58e32d083b287f44569526761bb32 /ardor3d-awt
parent105f890b5e750aaa5ec63e768e77eca2af8631a4 (diff)
parent9dd02f103042cb8a196f8a3ed2278da443e345bf (diff)
Merge branch 'kill_trunk' into dependencies
Diffstat (limited to 'ardor3d-awt')
-rw-r--r--ardor3d-awt/.settings/org.eclipse.jdt.core.prefs276
-rw-r--r--ardor3d-awt/.settings/org.eclipse.jdt.ui.prefs114
-rw-r--r--ardor3d-awt/pom.xml40
-rw-r--r--ardor3d-awt/src/main/java/com/ardor3d/image/util/AWTImageLoader.java267
-rw-r--r--ardor3d-awt/src/main/java/com/ardor3d/image/util/AWTImageUtil.java132
-rw-r--r--ardor3d-awt/src/main/java/com/ardor3d/image/util/AWTTextureUtil.java43
-rw-r--r--ardor3d-awt/src/main/java/com/ardor3d/image/util/AwtColorUtil.java38
-rw-r--r--ardor3d-awt/src/main/java/com/ardor3d/image/util/ScreenShotImageExporter.java156
-rw-r--r--ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtFocusWrapper.java50
-rw-r--r--ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtKey.java154
-rw-r--r--ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtKeyboardWrapper.java126
-rw-r--r--ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseManager.java167
-rw-r--r--ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseWrapper.java326
-rw-r--r--ardor3d-awt/src/test/java/com/ardor3d/input/awt/TestAwtKeyboardWrapper.java107
14 files changed, 1996 insertions, 0 deletions
diff --git a/ardor3d-awt/.settings/org.eclipse.jdt.core.prefs b/ardor3d-awt/.settings/org.eclipse.jdt.core.prefs
new file mode 100644
index 0000000..9446d01
--- /dev/null
+++ b/ardor3d-awt/.settings/org.eclipse.jdt.core.prefs
@@ -0,0 +1,276 @@
+#Tue Apr 06 11:25:13 CDT 2010
+eclipse.preferences.version=1
+org.eclipse.jdt.core.codeComplete.argumentPrefixes=
+org.eclipse.jdt.core.codeComplete.argumentSuffixes=
+org.eclipse.jdt.core.codeComplete.fieldPrefixes=_
+org.eclipse.jdt.core.codeComplete.fieldSuffixes=
+org.eclipse.jdt.core.codeComplete.localPrefixes=
+org.eclipse.jdt.core.codeComplete.localSuffixes=
+org.eclipse.jdt.core.codeComplete.staticFieldPrefixes=
+org.eclipse.jdt.core.codeComplete.staticFieldSuffixes=
+org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled
+org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6
+org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve
+org.eclipse.jdt.core.compiler.compliance=1.6
+org.eclipse.jdt.core.compiler.debug.lineNumber=generate
+org.eclipse.jdt.core.compiler.debug.localVariable=generate
+org.eclipse.jdt.core.compiler.debug.sourceFile=generate
+org.eclipse.jdt.core.compiler.problem.assertIdentifier=error
+org.eclipse.jdt.core.compiler.problem.enumIdentifier=error
+org.eclipse.jdt.core.compiler.source=1.6
+org.eclipse.jdt.core.formatter.align_type_members_on_columns=false
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_enum_constant=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_explicit_constructor_call=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_arguments_in_qualified_allocation_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_assignment=0
+org.eclipse.jdt.core.formatter.alignment_for_binary_expression=16
+org.eclipse.jdt.core.formatter.alignment_for_compact_if=16
+org.eclipse.jdt.core.formatter.alignment_for_conditional_expression=80
+org.eclipse.jdt.core.formatter.alignment_for_enum_constants=0
+org.eclipse.jdt.core.formatter.alignment_for_expressions_in_array_initializer=16
+org.eclipse.jdt.core.formatter.alignment_for_multiple_fields=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_parameters_in_method_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_selector_in_method_invocation=16
+org.eclipse.jdt.core.formatter.alignment_for_superclass_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_enum_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_superinterfaces_in_type_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_constructor_declaration=16
+org.eclipse.jdt.core.formatter.alignment_for_throws_clause_in_method_declaration=16
+org.eclipse.jdt.core.formatter.blank_lines_after_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_after_package=1
+org.eclipse.jdt.core.formatter.blank_lines_before_field=0
+org.eclipse.jdt.core.formatter.blank_lines_before_first_class_body_declaration=0
+org.eclipse.jdt.core.formatter.blank_lines_before_imports=1
+org.eclipse.jdt.core.formatter.blank_lines_before_member_type=1
+org.eclipse.jdt.core.formatter.blank_lines_before_method=1
+org.eclipse.jdt.core.formatter.blank_lines_before_new_chunk=1
+org.eclipse.jdt.core.formatter.blank_lines_before_package=1
+org.eclipse.jdt.core.formatter.blank_lines_between_import_groups=1
+org.eclipse.jdt.core.formatter.blank_lines_between_type_declarations=1
+org.eclipse.jdt.core.formatter.brace_position_for_annotation_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_anonymous_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_array_initializer=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_block_in_case=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_constructor_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_constant=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_enum_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_method_declaration=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_switch=end_of_line
+org.eclipse.jdt.core.formatter.brace_position_for_type_declaration=end_of_line
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_block_comment=false
+org.eclipse.jdt.core.formatter.comment.clear_blank_lines_in_javadoc_comment=false
+org.eclipse.jdt.core.formatter.comment.format_block_comments=true
+org.eclipse.jdt.core.formatter.comment.format_header=false
+org.eclipse.jdt.core.formatter.comment.format_html=true
+org.eclipse.jdt.core.formatter.comment.format_javadoc_comments=true
+org.eclipse.jdt.core.formatter.comment.format_line_comments=true
+org.eclipse.jdt.core.formatter.comment.format_source_code=true
+org.eclipse.jdt.core.formatter.comment.indent_parameter_description=true
+org.eclipse.jdt.core.formatter.comment.indent_root_tags=true
+org.eclipse.jdt.core.formatter.comment.insert_new_line_before_root_tags=insert
+org.eclipse.jdt.core.formatter.comment.insert_new_line_for_parameter=insert
+org.eclipse.jdt.core.formatter.comment.line_length=120
+org.eclipse.jdt.core.formatter.compact_else_if=true
+org.eclipse.jdt.core.formatter.continuation_indentation=2
+org.eclipse.jdt.core.formatter.continuation_indentation_for_array_initializer=2
+org.eclipse.jdt.core.formatter.format_guardian_clause_on_one_line=false
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_annotation_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_constant_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_enum_declaration_header=true
+org.eclipse.jdt.core.formatter.indent_body_declarations_compare_to_type_header=true
+org.eclipse.jdt.core.formatter.indent_breaks_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_empty_lines=false
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_block=true
+org.eclipse.jdt.core.formatter.indent_statements_compare_to_body=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_cases=true
+org.eclipse.jdt.core.formatter.indent_switchstatements_compare_to_switch=true
+org.eclipse.jdt.core.formatter.indentation.size=4
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_local_variable=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_member=insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_annotation_on_parameter=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_after_opening_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_at_end_of_file_if_missing=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_catch_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_closing_brace_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_else_in_if_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_finally_in_try_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_before_while_in_do_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_annotation_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_anonymous_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_block=insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_enum_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_method_body=do not insert
+org.eclipse.jdt.core.formatter.insert_new_line_in_empty_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_after_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_at_in_annotation_type_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_angle_bracket_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_after_closing_paren_in_cast=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_case=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_colon_in_labeled_statement=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_allocation_expression=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_annotation=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_constructor_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_constant_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_enum_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_explicitconstructorcall_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_increments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_for_inits=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_declaration_throws=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_method_invocation_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_field_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_multiple_local_declarations=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_parameterized_type_reference=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_superinterfaces=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_arguments=insert
+org.eclipse.jdt.core.formatter.insert_space_after_comma_in_type_parameters=insert
+org.eclipse.jdt.core.formatter.insert_space_after_ellipsis=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_opening_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_after_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_after_semicolon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_after_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_and_in_type_parameter=insert
+org.eclipse.jdt.core.formatter.insert_space_before_assignment_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_at_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_binary_operator=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_cast=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_catch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_if=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_switch=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_synchronized=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_closing_paren_in_while=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_assert=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_case=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_default=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_colon_in_labeled_statement=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_constructor_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_constant_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_enum_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_explicitconstructorcall_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_increments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_for_inits=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_declaration_throws=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_method_invocation_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_field_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_multiple_local_declarations=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_superinterfaces=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_comma_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_ellipsis=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_parameterized_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_arguments=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_angle_bracket_in_type_parameters=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_annotation_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_anonymous_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_array_initializer=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_block=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_constructor_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_constant=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_enum_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_method_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_brace_in_type_declaration=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_bracket_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_catch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_for=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_if=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_parenthesized_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_switch=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_synchronized=insert
+org.eclipse.jdt.core.formatter.insert_space_before_opening_paren_in_while=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_return=insert
+org.eclipse.jdt.core.formatter.insert_space_before_parenthesized_expression_in_throw=insert
+org.eclipse.jdt.core.formatter.insert_space_before_postfix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_prefix_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_conditional=insert
+org.eclipse.jdt.core.formatter.insert_space_before_question_in_wildcard=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_semicolon_in_for=do not insert
+org.eclipse.jdt.core.formatter.insert_space_before_unary_operator=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_brackets_in_array_type_reference=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_braces_in_array_initializer=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_brackets_in_array_allocation_expression=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_annotation_type_member_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_constructor_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_enum_constant=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_declaration=do not insert
+org.eclipse.jdt.core.formatter.insert_space_between_empty_parens_in_method_invocation=do not insert
+org.eclipse.jdt.core.formatter.keep_else_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.keep_empty_array_initializer_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_imple_if_on_one_line=false
+org.eclipse.jdt.core.formatter.keep_then_statement_on_same_line=false
+org.eclipse.jdt.core.formatter.lineSplit=120
+org.eclipse.jdt.core.formatter.never_indent_block_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.never_indent_line_comments_on_first_column=false
+org.eclipse.jdt.core.formatter.number_of_blank_lines_at_beginning_of_method_body=0
+org.eclipse.jdt.core.formatter.number_of_empty_lines_to_preserve=1
+org.eclipse.jdt.core.formatter.put_empty_statement_on_new_line=true
+org.eclipse.jdt.core.formatter.tabulation.char=space
+org.eclipse.jdt.core.formatter.tabulation.size=4
+org.eclipse.jdt.core.formatter.use_tabs_only_for_leading_indentations=false
+org.eclipse.jdt.core.formatter.wrap_before_binary_operator=true
diff --git a/ardor3d-awt/.settings/org.eclipse.jdt.ui.prefs b/ardor3d-awt/.settings/org.eclipse.jdt.ui.prefs
new file mode 100644
index 0000000..f479490
--- /dev/null
+++ b/ardor3d-awt/.settings/org.eclipse.jdt.ui.prefs
@@ -0,0 +1,114 @@
+#Sun Jan 04 11:43:23 CST 2009
+cleanup.add_default_serial_version_id=true
+cleanup.add_generated_serial_version_id=false
+cleanup.add_missing_annotations=true
+cleanup.add_missing_deprecated_annotations=true
+cleanup.add_missing_methods=true
+cleanup.add_missing_nls_tags=false
+cleanup.add_missing_override_annotations=true
+cleanup.add_serial_version_id=true
+cleanup.always_use_blocks=true
+cleanup.always_use_parentheses_in_expressions=true
+cleanup.always_use_this_for_non_static_field_access=false
+cleanup.always_use_this_for_non_static_method_access=false
+cleanup.convert_to_enhanced_for_loop=false
+cleanup.correct_indentation=true
+cleanup.format_source_code=true
+cleanup.format_source_code_changes_only=false
+cleanup.make_local_variable_final=true
+cleanup.make_parameters_final=true
+cleanup.make_private_fields_final=true
+cleanup.make_type_abstract_if_missing_method=false
+cleanup.make_variable_declarations_final=true
+cleanup.never_use_blocks=false
+cleanup.never_use_parentheses_in_expressions=false
+cleanup.organize_imports=true
+cleanup.qualify_static_field_accesses_with_declaring_class=false
+cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+cleanup.qualify_static_member_accesses_with_declaring_class=true
+cleanup.qualify_static_method_accesses_with_declaring_class=false
+cleanup.remove_private_constructors=true
+cleanup.remove_trailing_whitespaces=true
+cleanup.remove_trailing_whitespaces_all=true
+cleanup.remove_trailing_whitespaces_ignore_empty=false
+cleanup.remove_unnecessary_casts=true
+cleanup.remove_unnecessary_nls_tags=true
+cleanup.remove_unused_imports=true
+cleanup.remove_unused_local_variables=false
+cleanup.remove_unused_private_fields=true
+cleanup.remove_unused_private_members=false
+cleanup.remove_unused_private_methods=true
+cleanup.remove_unused_private_types=true
+cleanup.sort_members=false
+cleanup.sort_members_all=false
+cleanup.use_blocks=true
+cleanup.use_blocks_only_for_return_and_throw=false
+cleanup.use_parentheses_in_expressions=false
+cleanup.use_this_for_non_static_field_access=true
+cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+cleanup.use_this_for_non_static_method_access=true
+cleanup.use_this_for_non_static_method_access_only_if_necessary=true
+cleanup_profile=_ArdorLabs
+cleanup_settings_version=2
+eclipse.preferences.version=1
+editor_save_participant_org.eclipse.jdt.ui.postsavelistener.cleanup=true
+formatter_profile=_ArdorLabs
+formatter_settings_version=11
+org.eclipse.jdt.ui.exception.name=ex
+org.eclipse.jdt.ui.gettersetter.use.is=true
+org.eclipse.jdt.ui.javadoc=false
+org.eclipse.jdt.ui.keywordthis=false
+org.eclipse.jdt.ui.overrideannotation=true
+org.eclipse.jdt.ui.text.custom_code_templates=<?xml version\="1.0" encoding\="UTF-8" standalone\="no"?><templates><template autoinsert\="true" context\="gettercomment_context" deleted\="false" description\="Comment for getter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.gettercomment" name\="gettercomment">/**\r\n * @return the ${bare_field_name}\r\n */</template><template autoinsert\="true" context\="settercomment_context" deleted\="false" description\="Comment for setter method" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.settercomment" name\="settercomment">/**\r\n * @param ${param} the ${bare_field_name} to set\r\n */</template><template autoinsert\="true" context\="constructorcomment_context" deleted\="false" description\="Comment for created constructors" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorcomment" name\="constructorcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="filecomment_context" deleted\="false" description\="Comment for created Java files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.filecomment" name\="filecomment">/**\r\n * \r\n */</template><template autoinsert\="false" context\="typecomment_context" deleted\="false" description\="Comment for created types" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.typecomment" name\="typecomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="true" context\="fieldcomment_context" deleted\="false" description\="Comment for fields" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.fieldcomment" name\="fieldcomment">/**\r\n * \r\n */</template><template autoinsert\="true" context\="methodcomment_context" deleted\="false" description\="Comment for non-overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodcomment" name\="methodcomment">/**\r\n * ${tags}\r\n */</template><template autoinsert\="false" context\="overridecomment_context" deleted\="false" description\="Comment for overriding methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.overridecomment" name\="overridecomment"/><template autoinsert\="true" context\="delegatecomment_context" deleted\="false" description\="Comment for delegate methods" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.delegatecomment" name\="delegatecomment">/**\r\n * ${tags}\r\n * ${see_to_target}\r\n */</template><template autoinsert\="false" context\="newtype_context" deleted\="false" description\="Newly created files" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.newtype" name\="newtype">/**\r\n * Copyright (c) 2008-2010 Ardor Labs, Inc.\r\n *\r\n * This file is part of Ardor3D.\r\n *\r\n * Ardor3D is free software\: you can redistribute it and/or modify it \r\n * under the terms of its license which may be found in the accompanying\r\n * LICENSE file or at &lt;http\://www.ardor3d.com/LICENSE&gt;.\r\n */\r\n\r\n${filecomment}\r\n${package_declaration}\r\n\r\n${typecomment}\r\n${type_declaration}</template><template autoinsert\="true" context\="classbody_context" deleted\="false" description\="Code in new class type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.classbody" name\="classbody">\r\n</template><template autoinsert\="true" context\="interfacebody_context" deleted\="false" description\="Code in new interface type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.interfacebody" name\="interfacebody">\r\n</template><template autoinsert\="true" context\="enumbody_context" deleted\="false" description\="Code in new enum type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.enumbody" name\="enumbody">\r\n</template><template autoinsert\="true" context\="annotationbody_context" deleted\="false" description\="Code in new annotation type bodies" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.annotationbody" name\="annotationbody">\r\n</template><template autoinsert\="true" context\="catchblock_context" deleted\="false" description\="Code in new catch blocks" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.catchblock" name\="catchblock">// ${todo} Auto-generated catch block\r\n${exception_var}.printStackTrace();</template><template autoinsert\="true" context\="methodbody_context" deleted\="false" description\="Code in created method stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.methodbody" name\="methodbody">// ${todo} Auto-generated method stub\r\n${body_statement}</template><template autoinsert\="true" context\="constructorbody_context" deleted\="false" description\="Code in created constructor stubs" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.constructorbody" name\="constructorbody">${body_statement}\r\n// ${todo} Auto-generated constructor stub</template><template autoinsert\="true" context\="getterbody_context" deleted\="false" description\="Code in created getters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.getterbody" name\="getterbody">return ${field};</template><template autoinsert\="true" context\="setterbody_context" deleted\="false" description\="Code in created setters" enabled\="true" id\="org.eclipse.jdt.ui.text.codetemplates.setterbody" name\="setterbody">${field} \= ${param};</template></templates>
+sp_cleanup.add_default_serial_version_id=true
+sp_cleanup.add_generated_serial_version_id=false
+sp_cleanup.add_missing_annotations=true
+sp_cleanup.add_missing_deprecated_annotations=true
+sp_cleanup.add_missing_methods=false
+sp_cleanup.add_missing_nls_tags=false
+sp_cleanup.add_missing_override_annotations=true
+sp_cleanup.add_serial_version_id=false
+sp_cleanup.always_use_blocks=true
+sp_cleanup.always_use_parentheses_in_expressions=false
+sp_cleanup.always_use_this_for_non_static_field_access=false
+sp_cleanup.always_use_this_for_non_static_method_access=false
+sp_cleanup.convert_to_enhanced_for_loop=false
+sp_cleanup.correct_indentation=true
+sp_cleanup.format_source_code=true
+sp_cleanup.format_source_code_changes_only=false
+sp_cleanup.make_local_variable_final=true
+sp_cleanup.make_parameters_final=true
+sp_cleanup.make_private_fields_final=true
+sp_cleanup.make_type_abstract_if_missing_method=false
+sp_cleanup.make_variable_declarations_final=true
+sp_cleanup.never_use_blocks=false
+sp_cleanup.never_use_parentheses_in_expressions=true
+sp_cleanup.on_save_use_additional_actions=true
+sp_cleanup.organize_imports=true
+sp_cleanup.qualify_static_field_accesses_with_declaring_class=false
+sp_cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
+sp_cleanup.qualify_static_member_accesses_with_declaring_class=true
+sp_cleanup.qualify_static_method_accesses_with_declaring_class=false
+sp_cleanup.remove_private_constructors=true
+sp_cleanup.remove_trailing_whitespaces=true
+sp_cleanup.remove_trailing_whitespaces_all=true
+sp_cleanup.remove_trailing_whitespaces_ignore_empty=false
+sp_cleanup.remove_unnecessary_casts=true
+sp_cleanup.remove_unnecessary_nls_tags=true
+sp_cleanup.remove_unused_imports=true
+sp_cleanup.remove_unused_local_variables=false
+sp_cleanup.remove_unused_private_fields=true
+sp_cleanup.remove_unused_private_members=false
+sp_cleanup.remove_unused_private_methods=true
+sp_cleanup.remove_unused_private_types=true
+sp_cleanup.sort_members=false
+sp_cleanup.sort_members_all=false
+sp_cleanup.use_blocks=true
+sp_cleanup.use_blocks_only_for_return_and_throw=false
+sp_cleanup.use_parentheses_in_expressions=false
+sp_cleanup.use_this_for_non_static_field_access=true
+sp_cleanup.use_this_for_non_static_field_access_only_if_necessary=true
+sp_cleanup.use_this_for_non_static_method_access=true
+sp_cleanup.use_this_for_non_static_method_access_only_if_necessary=true
diff --git a/ardor3d-awt/pom.xml b/ardor3d-awt/pom.xml
new file mode 100644
index 0000000..789692b
--- /dev/null
+++ b/ardor3d-awt/pom.xml
@@ -0,0 +1,40 @@
+<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
+ <modelVersion>4.0.0</modelVersion>
+ <parent>
+ <groupId>com.ardor3d</groupId>
+ <artifactId>ardor3d</artifactId>
+ <version>0.9-SNAPSHOT</version>
+ <relativePath>../pom.xml</relativePath>
+ </parent>
+
+ <artifactId>ardor3d-awt</artifactId>
+ <packaging>bundle</packaging>
+ <name>Ardor 3D AWT</name>
+ <build>
+ <plugins>
+ <plugin>
+ <groupId>org.apache.maven.plugins</groupId>
+ <artifactId>maven-compiler-plugin</artifactId>
+ <configuration>
+ <source>1.6</source>
+ <target>1.6</target>
+ <encoding>${project.build.sourceEncoding}</encoding>
+ </configuration>
+ </plugin>
+ </plugins>
+ </build>
+ <dependencies>
+ <dependency>
+ <groupId>${project.groupId}</groupId>
+ <artifactId>ardor3d-core</artifactId>
+ <version>${project.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>org.easymock</groupId>
+ <artifactId>easymockclassextension</artifactId>
+ </dependency>
+ </dependencies>
+ <properties>
+ <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
+ </properties>
+</project>
diff --git a/ardor3d-awt/src/main/java/com/ardor3d/image/util/AWTImageLoader.java b/ardor3d-awt/src/main/java/com/ardor3d/image/util/AWTImageLoader.java
new file mode 100644
index 0000000..86a93d3
--- /dev/null
+++ b/ardor3d-awt/src/main/java/com/ardor3d/image/util/AWTImageLoader.java
@@ -0,0 +1,267 @@
+/**
+ * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ *
+ * This file is part of Ardor3D.
+ *
+ * Ardor3D is free software: you can redistribute it and/or modify it
+ * under the terms of its license which may be found in the accompanying
+ * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
+ */
+
+package com.ardor3d.image.util;
+
+import java.awt.image.BufferedImage;
+import java.awt.image.ColorModel;
+import java.awt.image.DataBuffer;
+import java.awt.image.Raster;
+import java.awt.image.RenderedImage;
+import java.awt.image.renderable.RenderableImage;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.List;
+import java.util.logging.Logger;
+
+import javax.imageio.ImageIO;
+
+import com.ardor3d.image.Image;
+import com.ardor3d.image.ImageDataFormat;
+import com.ardor3d.image.PixelDataType;
+import com.ardor3d.renderer.state.TextureState;
+import com.ardor3d.util.geom.BufferUtils;
+import com.google.common.collect.Lists;
+
+/**
+ * Image loader that makes use of AWT's ImageIO to load image file data.
+ */
+public class AWTImageLoader implements ImageLoader {
+ private static final Logger logger = Logger.getLogger(AWTImageLoader.class.getName());
+
+ private static boolean createOnHeap = false;
+
+ private static String[] supportedFormats;
+
+ public static String[] getSupportedFormats() {
+ return supportedFormats;
+ }
+
+ public static void registerLoader() {
+ if (supportedFormats == null) {
+ final List<String> formats = Lists.newArrayList();
+ for (String format : ImageIO.getReaderFormatNames()) {
+ format = "." + format.toUpperCase();
+ if (!formats.contains(format)) {
+ formats.add(format);
+ }
+ }
+ supportedFormats = formats.toArray(new String[formats.size()]);
+ }
+ ImageLoaderUtil.registerHandler(new AWTImageLoader(), supportedFormats);
+ }
+
+ public Image load(final InputStream is, final boolean flipImage) throws IOException {
+ final BufferedImage image = ImageIO.read(is);
+ if (image == null) {
+ return null;
+ }
+
+ return makeArdor3dImage(image, flipImage);
+ }
+
+ public static Image makeArdor3dImage(final BufferedImage image, final boolean flipImage) {
+ if (image == null) {
+ return null;
+ }
+
+ final boolean hasAlpha = image.getColorModel().hasAlpha();
+ final boolean grayscale = image.getColorModel().getNumComponents() == 1;
+ BufferedImage tex;
+
+ if (flipImage
+ || ((image).getType() != BufferedImage.TYPE_BYTE_GRAY && (hasAlpha ? (image).getType() != BufferedImage.TYPE_4BYTE_ABGR
+ : (image).getType() != BufferedImage.TYPE_3BYTE_BGR))) {
+ // Obtain the image data.
+ try {
+ tex = new BufferedImage(image.getWidth(null), image.getHeight(null),
+ grayscale ? BufferedImage.TYPE_BYTE_GRAY : hasAlpha ? BufferedImage.TYPE_4BYTE_ABGR
+ : BufferedImage.TYPE_3BYTE_BGR);
+ } catch (final IllegalArgumentException e) {
+ logger.warning("Problem creating buffered Image: " + e.getMessage());
+ return TextureState.getDefaultTextureImage();
+ }
+
+ final int imageWidth = image.getWidth(null);
+ final int imageHeight = image.getHeight(null);
+ final int[] tmpData = new int[imageWidth];
+ int row = 0;
+ for (int y = imageHeight - 1; y >= 0; y--) {
+ image.getRGB(0, (flipImage ? row++ : y), imageWidth, 1, tmpData, 0, imageWidth);
+ tex.setRGB(0, y, imageWidth, 1, tmpData, 0, imageWidth);
+ }
+
+ } else {
+ tex = image;
+ }
+
+ // Get a pointer to the image memory
+ final byte data[] = asByteArray(tex);
+ final ByteBuffer scratch = createOnHeap ? BufferUtils.createByteBufferOnHeap(data.length) : BufferUtils
+ .createByteBuffer(data.length);
+ scratch.clear();
+ scratch.put(data);
+ scratch.flip();
+ final Image ardorImage = new Image();
+ ardorImage.setDataFormat(grayscale ? ImageDataFormat.Luminance : hasAlpha ? ImageDataFormat.RGBA
+ : ImageDataFormat.RGB);
+ ardorImage.setDataType(PixelDataType.UnsignedByte);
+ ardorImage.setWidth(tex.getWidth());
+ ardorImage.setHeight(tex.getHeight());
+ ardorImage.setData(scratch);
+ return ardorImage;
+ }
+
+ public static Image makeArdor3dImage(final RenderableImage image, final boolean flipImage) {
+ return makeArdor3dImage(image.createDefaultRendering(), flipImage);
+ }
+
+ public static Image makeArdor3dImage(final RenderedImage image, final boolean flipImage) {
+ if (image == null) {
+ return null;
+ }
+
+ final ColorModel colorModel = image.getColorModel();
+ final boolean hasAlpha = colorModel.hasAlpha();
+ final boolean grayscale = colorModel.getNumComponents() == 1;
+
+ // Get a pointer to the image memory
+ final byte data[] = asByteArray(image, grayscale, hasAlpha);
+ final ByteBuffer scratch = createOnHeap ? BufferUtils.createByteBufferOnHeap(data.length) : BufferUtils
+ .createByteBuffer(data.length);
+ scratch.clear();
+ scratch.put(data);
+ scratch.flip();
+ final Image ardorImage = new Image();
+ ardorImage.setDataFormat(grayscale ? ImageDataFormat.Luminance : hasAlpha ? ImageDataFormat.RGBA
+ : ImageDataFormat.RGB);
+ ardorImage.setDataType(PixelDataType.UnsignedByte);
+ ardorImage.setWidth(image.getWidth());
+ ardorImage.setHeight(image.getHeight());
+ ardorImage.setData(scratch);
+ return ardorImage;
+ }
+
+ public static byte[] asByteArray(final BufferedImage image) {
+ final int imageWidth = image.getWidth(null);
+ final int imageHeight = image.getHeight(null);
+ final boolean hasAlpha = image.getColorModel().hasAlpha();
+ final boolean grayscale = image.getColorModel().getNumComponents() == 1;
+
+ if (image.getRaster().getTransferType() == DataBuffer.TYPE_BYTE) {
+ return (byte[]) image.getRaster().getDataElements(0, 0, imageWidth, imageHeight, null);
+ }
+
+ final byte[] rVal = new byte[imageWidth * imageHeight * (grayscale ? 1 : (hasAlpha ? 4 : 3))];
+ final int[] tmpData = new int[imageWidth];
+ int index = 0;
+ for (int y = 0; y < imageHeight; y++) {
+ image.getRGB(0, y, imageWidth, 1, tmpData, 0, imageWidth);
+ for (int i = 0; i < imageWidth; i++) {
+ final int argb = tmpData[i];
+ if (grayscale) {
+ rVal[index++] = (byte) (argb & 0xFF);
+ } else {
+ rVal[index++] = (byte) ((argb >> 16) & 0xFF);
+ rVal[index++] = (byte) ((argb >> 8) & 0xFF);
+ rVal[index++] = (byte) (argb & 0xFF);
+ if (hasAlpha) {
+ rVal[index++] = (byte) ((argb >> 24) & 0xFF);
+ }
+ }
+ }
+ }
+ return rVal;
+ }
+
+ public static byte[] asByteArray(final RenderedImage image, final boolean isGreyscale, final boolean hasAlpha) {
+ final int imageWidth = image.getWidth();
+ final int imageHeight = image.getHeight();
+ final Raster raster = image.getData();
+
+ if (raster.getTransferType() == DataBuffer.TYPE_BYTE) {
+ return (byte[]) image.getData().getDataElements(0, 0, imageWidth, imageHeight, null);
+ }
+
+ final byte[] rVal = new byte[imageWidth * imageHeight * (isGreyscale ? 1 : (hasAlpha ? 4 : 3))];
+ final int[] tmpData = new int[imageWidth];
+ int index = 0;
+ for (int y = 0; y < imageHeight; y++) {
+ getRGB(raster, image.getColorModel(), 0, y, imageWidth, 1, tmpData, 0, imageWidth);
+ for (int i = 0; i < imageWidth; i++) {
+ final int argb = tmpData[i];
+ if (isGreyscale) {
+ rVal[index++] = (byte) (argb & 0xFF);
+ } else {
+ rVal[index++] = (byte) ((argb >> 16) & 0xFF);
+ rVal[index++] = (byte) ((argb >> 8) & 0xFF);
+ rVal[index++] = (byte) (argb & 0xFF);
+ if (hasAlpha) {
+ rVal[index++] = (byte) ((argb >> 24) & 0xFF);
+ }
+ }
+ }
+ }
+ return rVal;
+ }
+
+ /**
+ * Extract rgb values from raster using the colormodel.
+ */
+ private static int[] getRGB(final Raster raster, final ColorModel colorModel, final int startX, final int startY,
+ final int w, final int h, int[] rgbArray, final int offset, final int scansize) {
+ Object data;
+ final int nbands = raster.getNumBands();
+ final int dataType = raster.getDataBuffer().getDataType();
+ switch (dataType) {
+ case DataBuffer.TYPE_BYTE:
+ data = new byte[nbands];
+ break;
+ case DataBuffer.TYPE_USHORT:
+ data = new short[nbands];
+ break;
+ case DataBuffer.TYPE_INT:
+ data = new int[nbands];
+ break;
+ case DataBuffer.TYPE_FLOAT:
+ data = new float[nbands];
+ break;
+ case DataBuffer.TYPE_DOUBLE:
+ data = new double[nbands];
+ break;
+ default:
+ throw new IllegalArgumentException("Unknown data buffer type: " + dataType);
+ }
+
+ if (rgbArray == null) {
+ rgbArray = new int[offset + h * scansize];
+ }
+
+ int yoff = offset;
+ int off;
+ for (int y = startY; y < startY + h; y++, yoff += scansize) {
+ off = yoff;
+ for (int x = startX; x < startX + w; x++) {
+ rgbArray[off++] = colorModel.getRGB(raster.getDataElements(x, y, data));
+ }
+ }
+
+ return rgbArray;
+ }
+
+ public static void setCreateOnHeap(final boolean createOnHeap) {
+ AWTImageLoader.createOnHeap = createOnHeap;
+ }
+
+ public static boolean isCreateOnHeap() {
+ return createOnHeap;
+ }
+}
diff --git a/ardor3d-awt/src/main/java/com/ardor3d/image/util/AWTImageUtil.java b/ardor3d-awt/src/main/java/com/ardor3d/image/util/AWTImageUtil.java
new file mode 100644
index 0000000..3a8fa19
--- /dev/null
+++ b/ardor3d-awt/src/main/java/com/ardor3d/image/util/AWTImageUtil.java
@@ -0,0 +1,132 @@
+/**
+ * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ *
+ * This file is part of Ardor3D.
+ *
+ * Ardor3D is free software: you can redistribute it and/or modify it
+ * under the terms of its license which may be found in the accompanying
+ * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
+ */
+
+package com.ardor3d.image.util;
+
+import java.awt.Color;
+import java.awt.image.BufferedImage;
+import java.nio.ByteBuffer;
+import java.util.List;
+
+import com.ardor3d.image.Image;
+import com.ardor3d.image.PixelDataType;
+import com.google.common.collect.Lists;
+
+/**
+ * Utility methods for converting Ardor3D Images to AWT BufferedImages.
+ */
+public abstract class AWTImageUtil {
+
+ /**
+ * Convert the given Ardor3D Image to a List of BufferedImages. It is a List because Ardor3D Images may contain
+ * multiple layers (for example, in the case of cube maps or 3D textures).
+ *
+ * @param input
+ * the Ardor3D Image to convert
+ * @return the BufferedImage(s) created in the conversion
+ */
+ public static List<BufferedImage> convertToAWT(final Image input) {
+ // convert, using a full white tint (i.e. no applied color change from original data.)
+ return convertToAWT(input, Color.WHITE);
+ }
+
+ /**
+ * Convert the given Ardor3D Image to a List of BufferedImages. It is a List because Ardor3D Images may contain
+ * multiple layers (for example, in the case of cube maps or 3D textures). The given AWT Color is used to modulate
+ * or "tint" the returned image.
+ *
+ * TODO: Add support for more formats.<br/>
+ * XXX: Note that only images of data type ImageDataType.UnsignedByte and ImageDataFormat of RGB or RGBA are
+ * currently supported.
+ *
+ * @param input
+ * the Ardor3D Image to convert
+ * @param tint
+ * the Color to apply to the generated image
+ * @return the BufferedImage(s) created in the conversion
+ */
+ public static List<BufferedImage> convertToAWT(final Image input, final Color tint) {
+ if (input.getDataType() != PixelDataType.UnsignedByte) {
+ throw new Error("Unhandled Ardor3D image data type: " + input.getDataType());
+ }
+ // count the number of layers we will be converting.
+ final int size = input.getData().size();
+
+ // grab our image width and height
+ final int width = input.getWidth(), height = input.getHeight();
+
+ // create our return list
+ final List<BufferedImage> rVal = Lists.newArrayList();
+
+ // Calculate our modulation or "tint" values per channel
+ final double tRed = tint != null ? tint.getRed() / 255. : 1.0;
+ final double tGreen = tint != null ? tint.getGreen() / 255. : 1.0;
+ final double tBlue = tint != null ? tint.getBlue() / 255. : 1.0;
+ final double tAlpha = tint != null ? tint.getAlpha() / 255. : 1.0;
+
+ // go through each layer
+ for (int i = 0; i < size; i++) {
+ BufferedImage image;
+ final ByteBuffer data = input.getData(i);
+ data.rewind();
+ boolean alpha = false;
+ switch (input.getDataFormat()) {
+ case RGBA:
+ alpha = true;
+ // Falls through on purpose.
+ case RGB:
+ if (alpha) {
+ image = new BufferedImage(width, height, BufferedImage.TYPE_INT_ARGB);
+ } else {
+ image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
+ }
+
+ int index,
+ r,
+ g,
+ b,
+ a,
+ argb;
+
+ // Go through each pixel
+ for (int x = 0; x < width; x++) {
+ for (int y = 0; y < height; y++) {
+ index = (alpha ? 4 : 3) * (y * width + x);
+ r = (int) Math.round(((data.get(index + 0)) & 0xFF) * tRed);
+ g = (int) Math.round(((data.get(index + 1)) & 0xFF) * tGreen);
+ b = (int) Math.round(((data.get(index + 2)) & 0xFF) * tBlue);
+
+ // convert to integer expression
+ argb = (r << 16) | (g << 8) | (b);
+
+ // add alpha, if applicable
+ if (alpha) {
+ a = (int) Math.round(((data.get(index + 3)) & 0xFF) * tAlpha);
+ argb |= (a & 0xFF) << 24;
+ }
+
+ // apply to image
+ image.setRGB(x, y, argb);
+ }
+ }
+ break;
+ default:
+ throw new Error("Unhandled image data format: " + input.getDataFormat());
+ }
+
+ // add to our list
+ rVal.add(image);
+ }
+
+ // return list
+ return rVal;
+ }
+
+}
diff --git a/ardor3d-awt/src/main/java/com/ardor3d/image/util/AWTTextureUtil.java b/ardor3d-awt/src/main/java/com/ardor3d/image/util/AWTTextureUtil.java
new file mode 100644
index 0000000..827b915
--- /dev/null
+++ b/ardor3d-awt/src/main/java/com/ardor3d/image/util/AWTTextureUtil.java
@@ -0,0 +1,43 @@
+/**
+ * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ *
+ * This file is part of Ardor3D.
+ *
+ * Ardor3D is free software: you can redistribute it and/or modify it
+ * under the terms of its license which may be found in the accompanying
+ * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
+ */
+
+package com.ardor3d.image.util;
+
+import java.awt.image.BufferedImage;
+
+import com.ardor3d.image.Image;
+import com.ardor3d.image.Texture;
+import com.ardor3d.image.TextureStoreFormat;
+import com.ardor3d.util.TextureKey;
+import com.ardor3d.util.TextureManager;
+
+public abstract class AWTTextureUtil {
+
+ /**
+ * Convenience Utility for loading a BufferedImage as an Ardor3D Texture.
+ *
+ * @param image
+ * our buffered image
+ * @param minFilter
+ * the filter for the near values. Used to determine if we should generate mipmaps.
+ * @param flipVertically
+ * If true, the image is flipped vertically during image conversion.
+ * @param storeFormat
+ * the specific format to use when storing this texture on the card.
+ * @return our new Texture.
+ */
+ public static final Texture loadTexture(final BufferedImage image, final Texture.MinificationFilter minFilter,
+ final TextureStoreFormat storeFormat, final boolean flipVertically) {
+ final Image imageData = AWTImageLoader.makeArdor3dImage(image, flipVertically);
+ final String fileType = (image != null) ? "" + image.hashCode() : null;
+ final TextureKey tkey = TextureKey.getKey(null, flipVertically, storeFormat, fileType, minFilter);
+ return TextureManager.loadFromKey(tkey, imageData, null);
+ }
+}
diff --git a/ardor3d-awt/src/main/java/com/ardor3d/image/util/AwtColorUtil.java b/ardor3d-awt/src/main/java/com/ardor3d/image/util/AwtColorUtil.java
new file mode 100644
index 0000000..be24c26
--- /dev/null
+++ b/ardor3d-awt/src/main/java/com/ardor3d/image/util/AwtColorUtil.java
@@ -0,0 +1,38 @@
+/**
+ * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ *
+ * This file is part of Ardor3D.
+ *
+ * Ardor3D is free software: you can redistribute it and/or modify it
+ * under the terms of its license which may be found in the accompanying
+ * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
+ */
+
+package com.ardor3d.image.util;
+
+import java.awt.Color;
+
+import com.ardor3d.math.ColorRGBA;
+import com.ardor3d.math.type.ReadOnlyColorRGBA;
+
+public class AwtColorUtil {
+
+ public static ColorRGBA makeColorRGBA(final Color color) {
+ if (color == null) {
+ return new ColorRGBA(0, 0, 0, 1);
+ }
+ return new ColorRGBA(color.getRed() / 255f, color.getGreen() / 255f, color.getBlue() / 255f,
+ color.getAlpha() / 255f);
+ }
+
+ public static Color makeColor(final ReadOnlyColorRGBA color) {
+ return makeColor(color, true);
+ }
+
+ public static Color makeColor(final ReadOnlyColorRGBA color, final boolean useAlpha) {
+ if (color == null) {
+ return new Color(0, 0, 0, 1);
+ }
+ return new Color(color.getRed(), color.getGreen(), color.getBlue(), useAlpha ? color.getAlpha() : 1.0f);
+ }
+}
diff --git a/ardor3d-awt/src/main/java/com/ardor3d/image/util/ScreenShotImageExporter.java b/ardor3d-awt/src/main/java/com/ardor3d/image/util/ScreenShotImageExporter.java
new file mode 100644
index 0000000..3247d5e
--- /dev/null
+++ b/ardor3d-awt/src/main/java/com/ardor3d/image/util/ScreenShotImageExporter.java
@@ -0,0 +1,156 @@
+/**
+ * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ *
+ * This file is part of Ardor3D.
+ *
+ * Ardor3D is free software: you can redistribute it and/or modify it
+ * under the terms of its license which may be found in the accompanying
+ * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
+ */
+
+package com.ardor3d.image.util;
+
+import java.awt.image.BufferedImage;
+import java.io.File;
+import java.io.IOException;
+import java.nio.ByteBuffer;
+import java.util.logging.Level;
+import java.util.logging.Logger;
+
+import javax.imageio.ImageIO;
+
+import com.ardor3d.image.ImageDataFormat;
+import com.ardor3d.util.screen.ScreenExportable;
+
+public class ScreenShotImageExporter implements ScreenExportable {
+ private static final Logger logger = Logger.getLogger(ScreenShotImageExporter.class.getName());
+
+ protected File _directory;
+ protected String _prepend;
+ protected String _fileFormat;
+ protected boolean _useAlpha;
+
+ protected File _lastFile;
+
+ /**
+ * Make a new exporter with the default settings:
+ *
+ * <pre>
+ * directory: local working directory
+ * prepend: &quot;capture_&quot;
+ * format: &quot;png&quot;
+ * useAlpha: false
+ * </pre>
+ */
+ public ScreenShotImageExporter() {
+ this(new File(System.getProperty("user.dir")), "capture_", "png", false);
+ }
+
+ /**
+ * Construct a new exporter.
+ *
+ * @param directory
+ * the directory to save the screen shots in.
+ * @param prepend
+ * a value to prepend onto the generated file name. This must be at least 3 characters long.
+ * @param format
+ * the format to use for saving the image. ImageIO is used for this, so safe values are likely: "png",
+ * "jpg", "gif" and "bmp"
+ * @param useAlpha
+ * true for alpha values to be stored in image (as applicable, depending on the given format)
+ */
+ public ScreenShotImageExporter(final File directory, final String prepend, final String format,
+ final boolean useAlpha) {
+ _directory = directory;
+ _prepend = prepend;
+ _fileFormat = format;
+ _useAlpha = useAlpha;
+ }
+
+ public void export(final ByteBuffer data, final int width, final int height) {
+ final BufferedImage img = new BufferedImage(width, height, _useAlpha ? BufferedImage.TYPE_INT_ARGB
+ : BufferedImage.TYPE_INT_RGB);
+
+ int index, r, g, b, a;
+ int argb;
+ for (int x = 0; x < width; x++) {
+ for (int y = 0; y < height; y++) {
+ index = (_useAlpha ? 4 : 3) * ((height - y - 1) * width + x);
+ r = ((data.get(index + 0)));
+ g = ((data.get(index + 1)));
+ b = ((data.get(index + 2)));
+
+ argb = ((r & 0xFF) << 16) | ((g & 0xFF) << 8) | (b & 0xFF);
+
+ if (_useAlpha) {
+ a = ((data.get(index + 3)));
+ argb |= (a & 0xFF) << 24;
+ }
+
+ img.setRGB(x, y, argb);
+ }
+ }
+
+ try {
+ final File out = new File(_directory, _prepend + System.currentTimeMillis() + "." + _fileFormat);
+ logger.fine("Taking screenshot: " + out.getAbsolutePath());
+
+ // write out the screen shot image to a file.
+ ImageIO.write(img, _fileFormat, out);
+
+ // save our successful file to be accessed as desired.
+ _lastFile = out;
+ } catch (final IOException e) {
+ logger
+ .logp(Level.WARNING, getClass().getName(), "export(ByteBuffer, int, int)", e.getLocalizedMessage(),
+ e);
+ }
+ }
+
+ public ImageDataFormat getFormat() {
+ if (_useAlpha) {
+ return ImageDataFormat.RGBA;
+ } else {
+ return ImageDataFormat.RGB;
+ }
+ }
+
+ /**
+ * @return the last File written by this exporter, or null if none were written.
+ */
+ public File getLastFile() {
+ return _lastFile;
+ }
+
+ public File getDirectory() {
+ return _directory;
+ }
+
+ public void setDirectory(final File directory) {
+ _directory = directory;
+ }
+
+ public String getPrepend() {
+ return _prepend;
+ }
+
+ public void setPrepend(final String prepend) {
+ _prepend = prepend;
+ }
+
+ public boolean isUseAlpha() {
+ return _useAlpha;
+ }
+
+ public void setUseAlpha(final boolean useAlpha) {
+ _useAlpha = useAlpha;
+ }
+
+ public String getFileFormat() {
+ return _fileFormat;
+ }
+
+ public void setFileFormat(final String format) {
+ _fileFormat = format;
+ }
+}
diff --git a/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtFocusWrapper.java b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtFocusWrapper.java
new file mode 100644
index 0000000..5514856
--- /dev/null
+++ b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtFocusWrapper.java
@@ -0,0 +1,50 @@
+/**
+ * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ *
+ * This file is part of Ardor3D.
+ *
+ * Ardor3D is free software: you can redistribute it and/or modify it
+ * under the terms of its license which may be found in the accompanying
+ * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
+ */
+
+package com.ardor3d.input.awt;
+
+import java.awt.Component;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+
+import com.ardor3d.input.FocusWrapper;
+
+/**
+ * Focus listener class for use with AWT.
+ */
+public class AwtFocusWrapper implements FocusWrapper, FocusListener {
+ protected volatile boolean _focusLost = false;
+
+ protected final Component _component;
+
+ public AwtFocusWrapper(final Component component) {
+ _component = component;
+ }
+
+ public void focusGained(final FocusEvent e) {
+ // do nothing
+ }
+
+ public void focusLost(final FocusEvent e) {
+ _focusLost = true;
+ }
+
+ public boolean getAndClearFocusLost() {
+ final boolean result = _focusLost;
+
+ _focusLost = false;
+
+ return result;
+ }
+
+ public void init() {
+ _component.addFocusListener(this);
+ }
+}
diff --git a/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtKey.java b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtKey.java
new file mode 100644
index 0000000..f464154
--- /dev/null
+++ b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtKey.java
@@ -0,0 +1,154 @@
+/**
+ * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ *
+ * This file is part of Ardor3D.
+ *
+ * Ardor3D is free software: you can redistribute it and/or modify it
+ * under the terms of its license which may be found in the accompanying
+ * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
+ */
+
+package com.ardor3d.input.awt;
+
+import java.awt.event.KeyEvent;
+
+import com.ardor3d.input.Key;
+
+/**
+ * Enum used for translations between AWT key codes and Ardor3D {@link Key} instances.
+ */
+public enum AwtKey {
+
+ ZERO(KeyEvent.VK_0, Key.ZERO), //
+ ONE(KeyEvent.VK_1, Key.ONE), //
+ TWO(KeyEvent.VK_2, Key.TWO), //
+ THREE(KeyEvent.VK_3, Key.THREE), //
+ FOUR(KeyEvent.VK_4, Key.FOUR), //
+ FIVE(KeyEvent.VK_5, Key.FIVE), //
+ SIX(KeyEvent.VK_6, Key.SIX), //
+ SEVEN(KeyEvent.VK_7, Key.SEVEN), //
+ EIGHT(KeyEvent.VK_8, Key.EIGHT), //
+ NINE(KeyEvent.VK_9, Key.NINE), //
+ A(KeyEvent.VK_A, Key.A), //
+ ADD(KeyEvent.VK_ADD, Key.NUMPADADD), //
+ AT(KeyEvent.VK_AT, Key.AT), //
+ B(KeyEvent.VK_B, Key.B), //
+ BACK_QUOTE(KeyEvent.VK_BACK_QUOTE, Key.GRAVE), //
+ BACK_SPACE(KeyEvent.VK_BACK_SPACE, Key.BACK), //
+ BACK_SLASH(KeyEvent.VK_BACK_SLASH, Key.BACKSLASH), //
+ C(KeyEvent.VK_C, Key.C), //
+ CAPS_LOCK(KeyEvent.VK_CAPS_LOCK, Key.CAPITAL), //
+ CIRCUMFLEX(KeyEvent.VK_CIRCUMFLEX, Key.CIRCUMFLEX), //
+ COLON(KeyEvent.VK_COLON, Key.COLON), //
+ COMMA(KeyEvent.VK_COMMA, Key.COMMA), //
+ CONVERT(KeyEvent.VK_CONVERT, Key.CONVERT), //
+ D(KeyEvent.VK_D, Key.D), //
+ DECIMAL(KeyEvent.VK_DECIMAL, Key.DECIMAL), //
+ DELETE(KeyEvent.VK_DELETE, Key.DELETE), //
+ DIVIDE(KeyEvent.VK_DIVIDE, Key.DIVIDE), //
+ DOWN(KeyEvent.VK_DOWN, Key.DOWN), //
+ E(KeyEvent.VK_E, Key.E), //
+ END(KeyEvent.VK_END, Key.END), //
+ EQUALS(KeyEvent.VK_EQUALS, Key.EQUALS), //
+ ESCAPE(KeyEvent.VK_ESCAPE, Key.ESCAPE), //
+ F(KeyEvent.VK_F, Key.F), //
+ F1(KeyEvent.VK_F1, Key.F1), //
+ F2(KeyEvent.VK_F2, Key.F2), //
+ F3(KeyEvent.VK_F3, Key.F3), //
+ F4(KeyEvent.VK_F4, Key.F4), //
+ F5(KeyEvent.VK_F5, Key.F5), //
+ F6(KeyEvent.VK_F6, Key.F6), //
+ F7(KeyEvent.VK_F7, Key.F7), //
+ F8(KeyEvent.VK_F8, Key.F8), //
+ F9(KeyEvent.VK_F9, Key.F9), //
+ F10(KeyEvent.VK_F10, Key.F10), //
+ F11(KeyEvent.VK_F11, Key.F11), //
+ F12(KeyEvent.VK_F12, Key.F12), //
+ F13(KeyEvent.VK_F13, Key.F13), //
+ F14(KeyEvent.VK_F14, Key.F14), //
+ F15(KeyEvent.VK_F15, Key.F15), //
+ G(KeyEvent.VK_G, Key.G), //
+ H(KeyEvent.VK_H, Key.H), //
+ HOME(KeyEvent.VK_HOME, Key.HOME), //
+ I(KeyEvent.VK_I, Key.I), //
+ INSERT(KeyEvent.VK_INSERT, Key.INSERT), //
+ J(KeyEvent.VK_J, Key.J), //
+ K(KeyEvent.VK_K, Key.K), //
+ KANA(KeyEvent.VK_KANA, Key.KANA), //
+ KANJI(KeyEvent.VK_KANJI, Key.KANJI), //
+ L(KeyEvent.VK_L, Key.L), //
+ OPEN_BRACKET(KeyEvent.VK_OPEN_BRACKET, Key.LBRACKET), //
+ CONTROL(KeyEvent.VK_CONTROL, Key.LCONTROL), //
+ LEFT(KeyEvent.VK_LEFT, Key.LEFT), //
+ ALT(KeyEvent.VK_ALT, Key.LMENU), //
+ META(KeyEvent.VK_META, Key.LMETA), //
+ SHIFT(KeyEvent.VK_SHIFT, Key.LSHIFT), //
+ M(KeyEvent.VK_M, Key.M), //
+ MINUS(KeyEvent.VK_MINUS, Key.MINUS), //
+ MULTIPLY(KeyEvent.VK_MULTIPLY, Key.MULTIPLY), //
+ N(KeyEvent.VK_N, Key.N), //
+ PAGE_DOWN(KeyEvent.VK_PAGE_DOWN, Key.PAGEDOWN_NEXT), //
+ NONCONVERT(KeyEvent.VK_NONCONVERT, Key.NOCONVERT), //
+ NUM_LOCK(KeyEvent.VK_NUM_LOCK, Key.NUMLOCK), //
+ NUMPAD0(KeyEvent.VK_NUMPAD0, Key.NUMPAD0), //
+ NUMPAD1(KeyEvent.VK_NUMPAD1, Key.NUMPAD1), //
+ NUMPAD2(KeyEvent.VK_NUMPAD2, Key.NUMPAD2), //
+ NUMPAD3(KeyEvent.VK_NUMPAD3, Key.NUMPAD3), //
+ NUMPAD4(KeyEvent.VK_NUMPAD4, Key.NUMPAD4), //
+ NUMPAD5(KeyEvent.VK_NUMPAD5, Key.NUMPAD5), //
+ NUMPAD6(KeyEvent.VK_NUMPAD6, Key.NUMPAD6), //
+ NUMPAD7(KeyEvent.VK_NUMPAD7, Key.NUMPAD7), //
+ NUMPAD8(KeyEvent.VK_NUMPAD8, Key.NUMPAD8), //
+ NUMPAD9(KeyEvent.VK_NUMPAD9, Key.NUMPAD9), //
+ O(KeyEvent.VK_O, Key.O), //
+ P(KeyEvent.VK_P, Key.P), //
+ PAUSE(KeyEvent.VK_PAUSE, Key.PAUSE), //
+ PERIOD(KeyEvent.VK_PERIOD, Key.PERIOD), //
+ PAGE_UP(KeyEvent.VK_PAGE_UP, Key.PAGEUP_PRIOR), //
+ Q(KeyEvent.VK_Q, Key.Q), //
+ QUOTE(KeyEvent.VK_QUOTE, Key.APOSTROPHE), //
+ R(KeyEvent.VK_R, Key.R), //
+ CLOSE_BRACKET(KeyEvent.VK_CLOSE_BRACKET, Key.RBRACKET), //
+ ENTER(KeyEvent.VK_ENTER, Key.RETURN), //
+ RIGHT(KeyEvent.VK_RIGHT, Key.RIGHT), //
+ S(KeyEvent.VK_S, Key.S), //
+ SCROLL_LOCK(KeyEvent.VK_SCROLL_LOCK, Key.SCROLL), //
+ SEMICOLON(KeyEvent.VK_SEMICOLON, Key.SEMICOLON), //
+ SLASH(KeyEvent.VK_SLASH, Key.SLASH), //
+ SPACE(KeyEvent.VK_SPACE, Key.SPACE), //
+ STOP(KeyEvent.VK_STOP, Key.STOP), //
+ PRINTSCREEN(KeyEvent.VK_PRINTSCREEN, Key.SYSRQ), //
+ T(KeyEvent.VK_T, Key.T), //
+ TAB(KeyEvent.VK_TAB, Key.TAB), //
+ U(KeyEvent.VK_U, Key.U), //
+ UNDERSCORE(KeyEvent.VK_UNDERSCORE, Key.UNDERLINE), //
+ UP(KeyEvent.VK_UP, Key.UP), //
+ V(KeyEvent.VK_V, Key.V), //
+ W(KeyEvent.VK_W, Key.W), //
+ X(KeyEvent.VK_X, Key.X), //
+ Y(KeyEvent.VK_Y, Key.Y), //
+ Z(KeyEvent.VK_Z, Key.Z), //
+ UNDEFINED(KeyEvent.VK_UNDEFINED, Key.UNKNOWN);
+
+ private final int _awtCode;
+ private final Key _key;
+
+ private AwtKey(final int awtCode, final Key key) {
+ _awtCode = awtCode;
+ _key = key;
+ }
+
+ public static Key findByCode(final int awtCode) {
+ for (final AwtKey ak : values()) {
+ if (ak._awtCode == awtCode) {
+ return ak._key;
+ }
+ }
+
+ return Key.UNKNOWN;
+ }
+
+ public int getAwtCode() {
+ return _awtCode;
+ }
+}
diff --git a/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtKeyboardWrapper.java b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtKeyboardWrapper.java
new file mode 100644
index 0000000..5aa9a4d
--- /dev/null
+++ b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtKeyboardWrapper.java
@@ -0,0 +1,126 @@
+/**
+ * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ *
+ * This file is part of Ardor3D.
+ *
+ * Ardor3D is free software: you can redistribute it and/or modify it
+ * under the terms of its license which may be found in the accompanying
+ * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
+ */
+
+package com.ardor3d.input.awt;
+
+import java.awt.Component;
+import java.awt.event.FocusEvent;
+import java.awt.event.FocusListener;
+import java.awt.event.KeyListener;
+import java.util.EnumSet;
+import java.util.LinkedList;
+
+import com.ardor3d.annotation.GuardedBy;
+import com.ardor3d.input.Key;
+import com.ardor3d.input.KeyEvent;
+import com.ardor3d.input.KeyState;
+import com.ardor3d.input.KeyboardWrapper;
+import com.google.common.base.Preconditions;
+import com.google.common.collect.AbstractIterator;
+import com.google.common.collect.PeekingIterator;
+
+/**
+ * Keyboard wrapper class for use with AWT.
+ */
+public class AwtKeyboardWrapper implements KeyboardWrapper, KeyListener {
+ @GuardedBy("this")
+ protected final LinkedList<KeyEvent> _upcomingEvents = new LinkedList<KeyEvent>();
+
+ @GuardedBy("this")
+ protected AwtKeyboardIterator _currentIterator = null;
+
+ protected final Component _component;
+
+ protected boolean _consumeEvents = false;
+
+ protected final EnumSet<Key> _pressedList = EnumSet.noneOf(Key.class);
+
+ public AwtKeyboardWrapper(final Component component) {
+ _component = Preconditions.checkNotNull(component, "component");
+ }
+
+ public void init() {
+ _component.addKeyListener(this);
+ _component.addFocusListener(new FocusListener() {
+ public void focusLost(final FocusEvent e) {}
+
+ public void focusGained(final FocusEvent e) {
+ _pressedList.clear();
+ }
+ });
+ }
+
+ public synchronized PeekingIterator<KeyEvent> getEvents() {
+ if (_currentIterator == null || !_currentIterator.hasNext()) {
+ _currentIterator = new AwtKeyboardIterator();
+ }
+
+ return _currentIterator;
+ }
+
+ public synchronized void keyTyped(final java.awt.event.KeyEvent e) {
+ if (_consumeEvents) {
+ e.consume();
+ // ignore this event
+ }
+ }
+
+ public synchronized void keyPressed(final java.awt.event.KeyEvent e) {
+ final Key pressed = fromKeyEventToKey(e);
+ if (!_pressedList.contains(pressed)) {
+ _upcomingEvents.add(new KeyEvent(pressed, KeyState.DOWN, e.getKeyChar()));
+ _pressedList.add(pressed);
+ }
+ if (_consumeEvents) {
+ e.consume();
+ }
+ }
+
+ public synchronized void keyReleased(final java.awt.event.KeyEvent e) {
+ final Key released = fromKeyEventToKey(e);
+ _upcomingEvents.add(new KeyEvent(released, KeyState.UP, e.getKeyChar()));
+ _pressedList.remove(released);
+ if (_consumeEvents) {
+ e.consume();
+ }
+ }
+
+ /**
+ * Convert from AWT key event to Ardor3D Key. Override to provide additional or custom behavior.
+ *
+ * @param e
+ * the AWT KeyEvent received by the input system.
+ * @return an Ardor3D Key, to be forwarded to the Predicate/Trigger system.
+ */
+ public synchronized Key fromKeyEventToKey(final java.awt.event.KeyEvent e) {
+ return AwtKey.findByCode(e.getKeyCode());
+ }
+
+ private class AwtKeyboardIterator extends AbstractIterator<KeyEvent> implements PeekingIterator<KeyEvent> {
+ @Override
+ protected KeyEvent computeNext() {
+ synchronized (AwtKeyboardWrapper.this) {
+ if (_upcomingEvents.isEmpty()) {
+ return endOfData();
+ }
+
+ return _upcomingEvents.poll();
+ }
+ }
+ }
+
+ public boolean isConsumeEvents() {
+ return _consumeEvents;
+ }
+
+ public void setConsumeEvents(final boolean consumeEvents) {
+ _consumeEvents = consumeEvents;
+ }
+}
diff --git a/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseManager.java b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseManager.java
new file mode 100644
index 0000000..8841f3a
--- /dev/null
+++ b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseManager.java
@@ -0,0 +1,167 @@
+/**
+ * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ *
+ * This file is part of Ardor3D.
+ *
+ * Ardor3D is free software: you can redistribute it and/or modify it
+ * under the terms of its license which may be found in the accompanying
+ * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
+ */
+
+package com.ardor3d.input.awt;
+
+import java.awt.AWTException;
+import java.awt.Component;
+import java.awt.Cursor;
+import java.awt.Dimension;
+import java.awt.Frame;
+import java.awt.Point;
+import java.awt.Robot;
+import java.awt.Toolkit;
+import java.awt.image.BufferedImage;
+import java.lang.reflect.InvocationTargetException;
+import java.util.logging.Logger;
+
+import javax.swing.SwingUtilities;
+
+import com.ardor3d.image.util.AWTImageUtil;
+import com.ardor3d.input.GrabbedState;
+import com.ardor3d.input.MouseCursor;
+import com.ardor3d.input.MouseManager;
+
+/**
+ * Implementation of the {@link com.ardor3d.input.MouseManager} interface for use with AWT windows. This implementation
+ * supports the optional {@link #setGrabbed(com.ardor3d.input.GrabbedState)} and {@link #setPosition(int, int)} methods
+ * if an AWT robot can be created on the current system. The constructor takes an AWT {@link java.awt.Component}
+ * instance, for which the cursor is set. In a multi-canvas application, each canvas can have its own AwtMouseManager
+ * instance, or it is possible to use a single one for the AWT container that includes the canvases.
+ */
+public class AwtMouseManager implements MouseManager {
+ private static final Logger logger = Logger.getLogger(AwtMouseManager.class.getName());
+
+ private static Cursor _transparentCursor;
+
+ private final Component _component;
+ private Robot _robot;
+
+ /** our current grabbed state */
+ private GrabbedState _grabbedState;
+
+ /** Our cursor prior to a setGrabbed(GRABBED) operation. Stored to be used when cursor is "ungrabbed" */
+ private Cursor _pregrabCursor;
+
+ public AwtMouseManager(final Component component) {
+ _component = component;
+
+ // Attempt to make
+ try {
+ _robot = new Robot();
+ } catch (final AWTException ex) {
+ logger.warning("Unable to create java.awt.Robot. setPosition and setGrabbed will not be supported.");
+ }
+ }
+
+ public void setCursor(final MouseCursor cursor) {
+ if (cursor == MouseCursor.SYSTEM_DEFAULT) {
+ if (_grabbedState == GrabbedState.GRABBED) {
+ _pregrabCursor = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR);
+ } else {
+ _component.setCursor(Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR));
+ }
+ return;
+ }
+
+ final BufferedImage image = AWTImageUtil.convertToAWT(cursor.getImage()).get(0);
+
+ // the hotSpot values must be less than the Dimension returned by getBestCursorSize
+ final Dimension bestCursorSize = Toolkit.getDefaultToolkit().getBestCursorSize(cursor.getHotspotX(),
+ cursor.getHotspotY());
+ final Point hotSpot = new Point(Math.min(cursor.getHotspotX(), (int) bestCursorSize.getWidth() - 1), Math.min(
+ cursor.getHotspotY(), (int) bestCursorSize.getHeight() - 1));
+
+ final Cursor awtCursor = Toolkit.getDefaultToolkit().createCustomCursor(image, hotSpot, cursor.getName());
+ if (_grabbedState == GrabbedState.GRABBED) {
+ _pregrabCursor = awtCursor;
+ } else {
+ _component.setCursor(awtCursor);
+ }
+ }
+
+ public void setPosition(final int x, final int y) {
+ if (!isSetPositionSupported()) {
+ throw new UnsupportedOperationException();
+ }
+
+ try {
+ // Only queue up if we are not already in the event thread.
+ if (java.awt.EventQueue.isDispatchThread()) {
+ setMousePosition(x, y);
+ } else {
+ SwingUtilities.invokeAndWait(new Runnable() {
+ public void run() {
+ setMousePosition(x, y);
+ }
+ });
+ }
+ } catch (final InterruptedException ex) {
+ } catch (final InvocationTargetException ex) {
+ }
+ }
+
+ private void setMousePosition(final int ardorX, final int ardorY) {
+ Component c = _component;
+ if (c instanceof Frame && ((Frame) c).getComponentCount() > 0) {
+ c = ((Frame) c).getComponent(0);
+ }
+ final Point p = new Point(ardorX, c.getHeight() - ardorY);
+ SwingUtilities.convertPointToScreen(p, c);
+ _robot.mouseMove(p.x, p.y);
+ }
+
+ public void setGrabbed(final GrabbedState grabbedState) {
+ if (!isSetGrabbedSupported()) {
+ throw new UnsupportedOperationException();
+ }
+
+ // check if we should be here.
+ if (_grabbedState == grabbedState) {
+ return;
+ }
+
+ // remember our grabbed state mode.
+ _grabbedState = grabbedState;
+
+ if (grabbedState == GrabbedState.GRABBED) {
+ // remember our old cursor
+ _pregrabCursor = _component.getCursor();
+
+ // set our cursor to be invisible
+ _component.setCursor(getTransparentCursor());
+ } else {
+ // restore our old cursor
+ _component.setCursor(_pregrabCursor);
+ }
+ }
+
+ private static final Cursor getTransparentCursor() {
+ if (_transparentCursor == null) {
+ final BufferedImage cursorImage = new BufferedImage(1, 1, BufferedImage.TYPE_INT_ARGB);
+ cursorImage.setRGB(0, 0, 0);
+ _transparentCursor = Toolkit.getDefaultToolkit().createCustomCursor(cursorImage, new Point(0, 0),
+ "empty cursor");
+ }
+ return _transparentCursor;
+ }
+
+ public boolean isSetPositionSupported() {
+ return _robot != null;
+ }
+
+ public boolean isSetGrabbedSupported() {
+ return _robot != null;
+ }
+
+ public GrabbedState getGrabbed() {
+ return _grabbedState;
+ }
+} \ No newline at end of file
diff --git a/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseWrapper.java b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseWrapper.java
new file mode 100644
index 0000000..c64b70b
--- /dev/null
+++ b/ardor3d-awt/src/main/java/com/ardor3d/input/awt/AwtMouseWrapper.java
@@ -0,0 +1,326 @@
+/**
+ * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ *
+ * This file is part of Ardor3D.
+ *
+ * Ardor3D is free software: you can redistribute it and/or modify it
+ * under the terms of its license which may be found in the accompanying
+ * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
+ */
+
+package com.ardor3d.input.awt;
+
+import static com.google.common.base.Preconditions.checkNotNull;
+
+import java.awt.Component;
+import java.awt.Frame;
+import java.awt.event.MouseEvent;
+import java.awt.event.MouseListener;
+import java.awt.event.MouseMotionListener;
+import java.awt.event.MouseWheelEvent;
+import java.awt.event.MouseWheelListener;
+import java.util.EnumMap;
+import java.util.EnumSet;
+import java.util.LinkedList;
+
+import com.ardor3d.annotation.GuardedBy;
+import com.ardor3d.input.ButtonState;
+import com.ardor3d.input.GrabbedState;
+import com.ardor3d.input.MouseButton;
+import com.ardor3d.input.MouseManager;
+import com.ardor3d.input.MouseState;
+import com.ardor3d.input.MouseWrapper;
+import com.google.common.collect.AbstractIterator;
+import com.google.common.collect.EnumMultiset;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Multiset;
+import com.google.common.collect.PeekingIterator;
+
+/**
+ * Mouse wrapper class for use with AWT.
+ */
+public class AwtMouseWrapper implements MouseWrapper, MouseListener, MouseWheelListener, MouseMotionListener {
+ @GuardedBy("this")
+ protected final LinkedList<MouseState> _upcomingEvents = Lists.newLinkedList();
+
+ @GuardedBy("this")
+ protected AwtMouseIterator _currentIterator = null;
+
+ @GuardedBy("this")
+ protected MouseState _lastState = null;
+
+ protected boolean _consumeEvents = false;
+
+ protected final Component _component;
+ protected final Frame _frame;
+ protected final MouseManager _manager;
+
+ protected final Multiset<MouseButton> _clicks = EnumMultiset.create(MouseButton.class);
+ protected final EnumMap<MouseButton, Long> _lastClickTime = Maps.newEnumMap(MouseButton.class);
+ protected final EnumSet<MouseButton> _clickArmed = EnumSet.noneOf(MouseButton.class);
+
+ protected int _ignoreX = Integer.MAX_VALUE;
+ protected int _ignoreY = Integer.MAX_VALUE;
+
+ public AwtMouseWrapper(final Component component, final MouseManager manager) {
+ _manager = manager;
+ if (component instanceof Frame) {
+ _frame = (Frame) (_component = component);
+ } else {
+ _component = checkNotNull(component, "component");
+ _frame = null;
+ }
+ for (final MouseButton mb : MouseButton.values()) {
+ _lastClickTime.put(mb, 0L);
+ }
+ }
+
+ public void init() {
+ _component.addMouseListener(this);
+ _component.addMouseMotionListener(this);
+ _component.addMouseWheelListener(this);
+ }
+
+ public synchronized PeekingIterator<MouseState> getEvents() {
+ expireClickEvents();
+
+ if (_currentIterator == null || !_currentIterator.hasNext()) {
+ _currentIterator = new AwtMouseIterator();
+ }
+
+ return _currentIterator;
+ }
+
+ private void expireClickEvents() {
+ if (!_clicks.isEmpty()) {
+ for (final MouseButton mb : MouseButton.values()) {
+ if (System.currentTimeMillis() - _lastClickTime.get(mb) > MouseState.CLICK_TIME_MS) {
+ _clicks.setCount(mb, 0);
+ }
+ }
+ }
+ }
+
+ public synchronized void mousePressed(final MouseEvent e) {
+ final MouseButton b = getButtonForEvent(e);
+ if (_clickArmed.contains(b)) {
+ _clicks.setCount(b, 0);
+ }
+ _clickArmed.add(b);
+ _lastClickTime.put(b, System.currentTimeMillis());
+
+ initState(e);
+ if (_consumeEvents) {
+ e.consume();
+ }
+
+ final EnumMap<MouseButton, ButtonState> buttons = _lastState.getButtonStates();
+
+ setStateForButton(e, buttons, ButtonState.DOWN);
+
+ addNewState(e, buttons, null);
+ }
+
+ public synchronized void mouseReleased(final MouseEvent e) {
+ initState(e);
+ if (_consumeEvents) {
+ e.consume();
+ }
+
+ final EnumMap<MouseButton, ButtonState> buttons = _lastState.getButtonStates();
+
+ setStateForButton(e, buttons, ButtonState.UP);
+
+ final MouseButton b = getButtonForEvent(e);
+ if (_clickArmed.contains(b) && (System.currentTimeMillis() - _lastClickTime.get(b) <= MouseState.CLICK_TIME_MS)) {
+ _clicks.add(b); // increment count of clicks for button b.
+ // XXX: Note the double event add... this prevents sticky click counts, but is it the best way?
+ addNewState(e, buttons, EnumMultiset.create(_clicks));
+ } else {
+ _clicks.setCount(b, 0); // clear click count for button b.
+ }
+ _clickArmed.remove(b);
+
+ addNewState(e, buttons, null);
+ }
+
+ public synchronized void mouseDragged(final MouseEvent e) {
+ // forward to mouseMoved.
+ mouseMoved(e);
+ }
+
+ public synchronized void mouseMoved(final MouseEvent e) {
+ _clickArmed.clear();
+ _clicks.clear();
+
+ // check that we have a valid _lastState
+ initState(e);
+ if (_consumeEvents) {
+ e.consume();
+ }
+
+ // remember our current ardor3d position
+ final int oldX = _lastState.getX(), oldY = _lastState.getY();
+
+ // check the state against the "ignore next" values
+ if (_ignoreX != Integer.MAX_VALUE // shortcut to prevent dx/dy calculations
+ && (_ignoreX == getDX(e) && _ignoreY == getDY(e))) {
+
+ // we matched, so we'll consider this a "mouse pointer reset move"
+ // so reset ignore to let the next move event through.
+ _ignoreX = Integer.MAX_VALUE;
+ _ignoreY = Integer.MAX_VALUE;
+
+ // exit without adding an event to our queue
+ return;
+ }
+
+ // save our old "last state."
+ final MouseState _savedState = _lastState;
+
+ // Add our latest state info to the queue
+ addNewState(e, _lastState.getButtonStates(), null);
+
+ // If we have a valid move... should always be the case, but occasionally something slips through.
+ if (_lastState.getDx() != 0 || _lastState.getDy() != 0) {
+
+ // Ask our manager if we're currently "captured"
+ if (_manager.getGrabbed() == GrabbedState.GRABBED) {
+
+ // if so, set "ignore next" to the inverse of this move
+ _ignoreX = -_lastState.getDx();
+ _ignoreY = -_lastState.getDy();
+
+ // Move us back to our last position.
+ _manager.setPosition(oldX, oldY);
+
+ // And finally, revert our _lastState.
+ _lastState = _savedState;
+ } else {
+ // otherwise, set us to not ignore anything. This may be unnecessary, but prevents any possible
+ // "ignore" bleeding.
+ _ignoreX = Integer.MAX_VALUE;
+ _ignoreY = Integer.MAX_VALUE;
+ }
+ }
+ }
+
+ public void mouseWheelMoved(final MouseWheelEvent e) {
+ initState(e);
+
+ addNewState(e, _lastState.getButtonStates(), null);
+ if (_consumeEvents) {
+ e.consume();
+ }
+ }
+
+ private void initState(final MouseEvent mouseEvent) {
+ if (_lastState == null) {
+ _lastState = new MouseState(mouseEvent.getX(), getArdor3DY(mouseEvent), 0, 0, 0, null, null);
+ }
+ }
+
+ private void addNewState(final MouseEvent mouseEvent, final EnumMap<MouseButton, ButtonState> enumMap,
+ final Multiset<MouseButton> clicks) {
+ final MouseState newState = new MouseState(mouseEvent.getX(), getArdor3DY(mouseEvent), getDX(mouseEvent),
+ getDY(mouseEvent), (mouseEvent instanceof MouseWheelEvent ? ((MouseWheelEvent) mouseEvent)
+ .getWheelRotation() : 0), enumMap, clicks);
+
+ synchronized (AwtMouseWrapper.this) {
+ _upcomingEvents.add(newState);
+ }
+ _lastState = newState;
+ }
+
+ private int getDX(final MouseEvent e) {
+ return e.getX() - _lastState.getX();
+ }
+
+ private int getDY(final MouseEvent e) {
+ return getArdor3DY(e) - _lastState.getY();
+ }
+
+ /**
+ * @param e
+ * our mouseEvent
+ * @return the Y coordinate of the event, flipped relative to the component since we expect an origin in the lower
+ * left corner.
+ */
+ private int getArdor3DY(final MouseEvent e) {
+ final int height = (_frame != null && _frame.getComponentCount() > 0) ? _frame.getComponent(0).getHeight()
+ : _component.getHeight();
+ return height - e.getY();
+ }
+
+ private void setStateForButton(final MouseEvent e, final EnumMap<MouseButton, ButtonState> buttons,
+ final ButtonState buttonState) {
+ final MouseButton button = getButtonForEvent(e);
+ buttons.put(button, buttonState);
+ }
+
+ private MouseButton getButtonForEvent(final MouseEvent e) {
+ MouseButton button;
+ switch (e.getButton()) {
+ case MouseEvent.BUTTON1:
+ button = MouseButton.LEFT;
+ break;
+ case MouseEvent.BUTTON2:
+ button = MouseButton.MIDDLE;
+ break;
+ case MouseEvent.BUTTON3:
+ button = MouseButton.RIGHT;
+ break;
+ default:
+ throw new RuntimeException("unknown button: " + e.getButton());
+ }
+ return button;
+ }
+
+ private class AwtMouseIterator extends AbstractIterator<MouseState> implements PeekingIterator<MouseState> {
+ @Override
+ protected MouseState computeNext() {
+ synchronized (AwtMouseWrapper.this) {
+ if (_upcomingEvents.isEmpty()) {
+ return endOfData();
+ }
+
+ return _upcomingEvents.poll();
+ }
+
+ }
+ }
+
+ // -- The following interface methods are not used. --
+
+ public synchronized void mouseClicked(final MouseEvent e) {
+ // Yes, we could use the click count here, but in the interests of this working the same way as SWT and Native,
+ // we
+ // will do it the same way they do it.
+ if (_consumeEvents) {
+ e.consume();
+ }
+ }
+
+ public synchronized void mouseEntered(final MouseEvent e) {
+ // ignore this
+ if (_consumeEvents) {
+ e.consume();
+ }
+ }
+
+ public synchronized void mouseExited(final MouseEvent e) {
+ // ignore this
+ if (_consumeEvents) {
+ e.consume();
+ }
+ }
+
+ public boolean isConsumeEvents() {
+ return _consumeEvents;
+ }
+
+ public void setConsumeEvents(final boolean consumeEvents) {
+ _consumeEvents = consumeEvents;
+ }
+}
diff --git a/ardor3d-awt/src/test/java/com/ardor3d/input/awt/TestAwtKeyboardWrapper.java b/ardor3d-awt/src/test/java/com/ardor3d/input/awt/TestAwtKeyboardWrapper.java
new file mode 100644
index 0000000..a5d688d
--- /dev/null
+++ b/ardor3d-awt/src/test/java/com/ardor3d/input/awt/TestAwtKeyboardWrapper.java
@@ -0,0 +1,107 @@
+/**
+ * Copyright (c) 2008-2012 Ardor Labs, Inc.
+ *
+ * This file is part of Ardor3D.
+ *
+ * Ardor3D is free software: you can redistribute it and/or modify it
+ * under the terms of its license which may be found in the accompanying
+ * LICENSE file or at <http://www.ardor3d.com/LICENSE>.
+ */
+
+package com.ardor3d.input.awt;
+
+import static org.easymock.classextension.EasyMock.createMock;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+
+import java.awt.Component;
+import java.util.Iterator;
+
+import org.junit.Before;
+import org.junit.Test;
+
+import com.ardor3d.input.Key;
+import com.ardor3d.input.KeyEvent;
+import com.ardor3d.input.KeyState;
+
+public class TestAwtKeyboardWrapper {
+ AwtKeyboardWrapper kw;
+
+ Component control;
+
+ java.awt.event.KeyEvent e1, e2;
+
+ @Before
+ public void setup() throws Exception {
+ control = createMock("component", Component.class);
+
+ kw = new AwtKeyboardWrapper(control);
+ }
+
+ @Test
+ public void testKeys1() throws Exception {
+
+ e1 = new java.awt.event.KeyEvent(control, 0, 0, 0, AwtKey.A.getAwtCode(), 'a');
+
+ kw.keyPressed(e1);
+ kw.keyReleased(e1);
+
+ final Iterator<KeyEvent> events = kw.getEvents();
+
+ final KeyEvent event1 = events.next();
+ final KeyEvent event2 = events.next();
+
+ assertFalse("no more", events.hasNext());
+ assertFalse("no more", kw.getEvents().hasNext());
+
+ assertEquals("key a", Key.A, event1.getKey());
+ assertEquals("down", KeyState.DOWN, event1.getState());
+
+ assertEquals("key a", Key.A, event2.getKey());
+ assertEquals("up", KeyState.UP, event2.getState());
+ }
+
+ @Test
+ public void testKeys2() throws Exception {
+ e1 = new java.awt.event.KeyEvent(control, 0, 0, 0, AwtKey.A.getAwtCode(), 'a');
+ e2 = new java.awt.event.KeyEvent(control, 0, 0, 0, AwtKey.B.getAwtCode(), 'b');
+
+ kw.keyPressed(e1);
+ kw.keyPressed(e2);
+
+ final Iterator<KeyEvent> events = kw.getEvents();
+
+ final KeyEvent event1 = events.next();
+ final KeyEvent event2 = events.next();
+
+ assertFalse("no more", events.hasNext());
+ assertFalse("no more", kw.getEvents().hasNext());
+
+ assertEquals("key a", Key.A, event1.getKey());
+ assertEquals("down", KeyState.DOWN, event1.getState());
+
+ assertEquals("key b", Key.B, event2.getKey());
+ assertEquals("down", KeyState.DOWN, event2.getState());
+ }
+
+ // @Test
+ // public void testLostFocusKeyDown() throws Exception {
+ //
+ // e1 = new java.awt.event.KeyEvent(control, 0, 0, 0, AwtKey.AWT_KEY_A.getAwtCode(), 'a');
+ //
+ // kw.keyPressed(e1);
+ //
+ //
+ // Iterator<KeyEvent> events = kw.getEvents();
+ //
+ // KeyEvent event1 = events.next();
+ //
+ // assertFalse("no more", events.hasNext());
+ // assertFalse("no more", kw.getEvents().hasNext());
+ //
+ // assertEquals("key a", Key.A, event1.getKey());
+ // assertEquals("down", KeyState.DOWN, event1.getState());
+ // }
+ //
+ //
+} \ No newline at end of file