diff options
author | neothemachine <[email protected]> | 2013-02-21 16:40:08 +0100 |
---|---|---|
committer | neothemachine <[email protected]> | 2013-02-21 16:40:08 +0100 |
commit | f774bd917e9dfd8cf46e5ed66d41aad64477a238 (patch) | |
tree | 8d33aa0cf24165710d420c677f3336641223cff8 /ardor3d-awt | |
parent | edbc5c757c66d56eb2cffffa4076f0f2bfd6e748 (diff) |
normalized line endings
see
http://www.hanselman.com/blog/YoureJustAnotherCarriageReturnLineFeedInTheWall.aspx
and https://help.github.com/articles/dealing-with-line-endings
Diffstat (limited to 'ardor3d-awt')
-rw-r--r-- | ardor3d-awt/.settings/org.eclipse.jdt.ui.prefs | 226 | ||||
-rw-r--r-- | ardor3d-awt/pom.xml | 80 | ||||
-rw-r--r-- | ardor3d-awt/src/main/java/com/ardor3d/image/util/AWTImageLoader.java | 534 | ||||
-rw-r--r-- | ardor3d-awt/src/test/java/com/ardor3d/input/awt/TestAwtKeyboardWrapper.java | 212 |
4 files changed, 526 insertions, 526 deletions
diff --git a/ardor3d-awt/.settings/org.eclipse.jdt.ui.prefs b/ardor3d-awt/.settings/org.eclipse.jdt.ui.prefs index 7588391..2cb0f4c 100644 --- a/ardor3d-awt/.settings/org.eclipse.jdt.ui.prefs +++ b/ardor3d-awt/.settings/org.eclipse.jdt.ui.prefs @@ -1,113 +1,113 @@ -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 <http\://www.ardor3d.com/LICENSE>.\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
+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 <http\://www.ardor3d.com/LICENSE>.\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 index 789692b..176dfbd 100644 --- a/ardor3d-awt/pom.xml +++ b/ardor3d-awt/pom.xml @@ -1,40 +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>
+<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 index 86a93d3..a1f965e 100644 --- a/ardor3d-awt/src/main/java/com/ardor3d/image/util/AWTImageLoader.java +++ b/ardor3d-awt/src/main/java/com/ardor3d/image/util/AWTImageLoader.java @@ -1,267 +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;
- }
-}
+/** + * 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/test/java/com/ardor3d/input/awt/TestAwtKeyboardWrapper.java b/ardor3d-awt/src/test/java/com/ardor3d/input/awt/TestAwtKeyboardWrapper.java index a5d688d..c03137a 100644 --- a/ardor3d-awt/src/test/java/com/ardor3d/input/awt/TestAwtKeyboardWrapper.java +++ b/ardor3d-awt/src/test/java/com/ardor3d/input/awt/TestAwtKeyboardWrapper.java @@ -1,107 +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());
- // }
- //
- //
+/** + * 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 |