Skip to content

Commit 72b3d8e

Browse files
committed
Add Java Insight3DApplet demo.
1 parent ca2f53f commit 72b3d8e

14 files changed

Lines changed: 921 additions & 0 deletions

Java/Insight3DApplet/.classpath

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<classpath>
3+
<classpathentry kind="src" path="src" />
4+
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8" />
5+
<classpathentry kind="lib" path="jars/agi.foundation.core-2019r3.jar">
6+
<attributes>
7+
<attribute name="javadoc_location" value="jar:platform:/resource/Insight3DApplet/doc/agi.foundation.javadoc-2019r3.zip!/" />
8+
</attributes>
9+
</classpathentry>
10+
<classpathentry kind="lib" path="jars/agi.foundation.graphics-2019r3.jar">
11+
<attributes>
12+
<attribute name="javadoc_location" value="jar:platform:/resource/Insight3DApplet/doc/agi.foundation.javadoc-2019r3.zip!/" />
13+
<attribute name="org.eclipse.jdt.launching.CLASSPATH_ATTR_LIBRARY_PATH_ENTRY" value="Insight3DApplet/jars" />
14+
</attributes>
15+
</classpathentry>
16+
<classpathentry kind="lib" path="jars/agi.foundation.models-2019r3.jar">
17+
<attributes>
18+
<attribute name="javadoc_location" value="jar:platform:/resource/Insight3DApplet/doc/agi.foundation.javadoc-2019r3.zip!/" />
19+
</attributes>
20+
</classpathentry>
21+
<classpathentry kind="lib" path="jars/agi.foundation.platforms-2019r3.jar">
22+
<attributes>
23+
<attribute name="javadoc_location" value="jar:platform:/resource/Insight3DApplet/doc/agi.foundation.javadoc-2019r3.zip!/" />
24+
</attributes>
25+
</classpathentry>
26+
<classpathentry kind="lib" path="jars/agi.foundation.platforms.graphics-2019r3.jar">
27+
<attributes>
28+
<attribute name="javadoc_location" value="jar:platform:/resource/Insight3DApplet/doc/agi.foundation.javadoc-2019r3.zip!/" />
29+
</attributes>
30+
</classpathentry>
31+
<classpathentry kind="lib" path="jars/agi.foundation.terrainreaders-2019r3.jar">
32+
<attributes>
33+
<attribute name="javadoc_location" value="jar:platform:/resource/Insight3DApplet/doc/agi.foundation.javadoc-2019r3.zip!/" />
34+
</attributes>
35+
</classpathentry>
36+
<classpathentry kind="output" path="bin" />
37+
</classpath>

Java/Insight3DApplet/.project

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<projectDescription>
3+
<name>Insight3DApplet</name>
4+
<comment></comment>
5+
<projects>
6+
</projects>
7+
<buildSpec>
8+
<buildCommand>
9+
<name>org.eclipse.jdt.core.javabuilder</name>
10+
<arguments>
11+
</arguments>
12+
</buildCommand>
13+
</buildSpec>
14+
<natures>
15+
<nature>org.eclipse.jdt.core.javanature</nature>
16+
</natures>
17+
<linkedResources>
18+
<link>
19+
<name>jars</name>
20+
<type>2</type>
21+
<locationURI>$%7BPARENT-2-PROJECT_LOC%7D/Jars</locationURI>
22+
</link>
23+
<link>
24+
<name>doc</name>
25+
<type>2</type>
26+
<locationURI>$%7BPARENT-2-PROJECT_LOC%7D/Documentation</locationURI>
27+
</link>
28+
</linkedResources>
29+
<filteredResources>
30+
<filter>
31+
<id>1497896520584</id>
32+
<name></name>
33+
<type>10</type>
34+
<matcher>
35+
<id>org.eclipse.ui.ide.multiFilter</id>
36+
<arguments>1.0-name-matches-false-false-ant</arguments>
37+
</matcher>
38+
</filter>
39+
<filter>
40+
<id>1497896520587</id>
41+
<name></name>
42+
<type>10</type>
43+
<matcher>
44+
<id>org.eclipse.ui.ide.multiFilter</id>
45+
<arguments>1.0-name-matches-false-false-dist</arguments>
46+
</matcher>
47+
</filter>
48+
</filteredResources>
49+
</projectDescription>

Java/Insight3DApplet/.settings/org.eclipse.jdt.core.prefs

Lines changed: 326 additions & 0 deletions
Large diffs are not rendered by default.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
cleanup.add_default_serial_version_id=true
2+
cleanup.add_generated_serial_version_id=false
3+
cleanup.add_missing_annotations=true
4+
cleanup.add_missing_deprecated_annotations=true
5+
cleanup.add_missing_methods=false
6+
cleanup.add_missing_nls_tags=false
7+
cleanup.add_missing_override_annotations=true
8+
cleanup.add_missing_override_annotations_interface_methods=true
9+
cleanup.add_serial_version_id=false
10+
cleanup.always_use_blocks=true
11+
cleanup.always_use_parentheses_in_expressions=false
12+
cleanup.always_use_this_for_non_static_field_access=false
13+
cleanup.always_use_this_for_non_static_method_access=false
14+
cleanup.convert_functional_interfaces=true
15+
cleanup.convert_to_enhanced_for_loop=true
16+
cleanup.correct_indentation=false
17+
cleanup.format_source_code=false
18+
cleanup.format_source_code_changes_only=false
19+
cleanup.insert_inferred_type_arguments=false
20+
cleanup.make_local_variable_final=false
21+
cleanup.make_parameters_final=false
22+
cleanup.make_private_fields_final=true
23+
cleanup.make_type_abstract_if_missing_method=false
24+
cleanup.make_variable_declarations_final=true
25+
cleanup.never_use_blocks=false
26+
cleanup.never_use_parentheses_in_expressions=true
27+
cleanup.organize_imports=true
28+
cleanup.qualify_static_field_accesses_with_declaring_class=false
29+
cleanup.qualify_static_member_accesses_through_instances_with_declaring_class=true
30+
cleanup.qualify_static_member_accesses_through_subtypes_with_declaring_class=true
31+
cleanup.qualify_static_member_accesses_with_declaring_class=true
32+
cleanup.qualify_static_method_accesses_with_declaring_class=false
33+
cleanup.remove_private_constructors=true
34+
cleanup.remove_redundant_type_arguments=true
35+
cleanup.remove_trailing_whitespaces=true
36+
cleanup.remove_trailing_whitespaces_all=true
37+
cleanup.remove_trailing_whitespaces_ignore_empty=false
38+
cleanup.remove_unnecessary_casts=true
39+
cleanup.remove_unnecessary_nls_tags=true
40+
cleanup.remove_unused_imports=true
41+
cleanup.remove_unused_local_variables=false
42+
cleanup.remove_unused_private_fields=true
43+
cleanup.remove_unused_private_members=false
44+
cleanup.remove_unused_private_methods=true
45+
cleanup.remove_unused_private_types=true
46+
cleanup.sort_members=false
47+
cleanup.sort_members_all=false
48+
cleanup.use_anonymous_class_creation=false
49+
cleanup.use_blocks=false
50+
cleanup.use_blocks_only_for_return_and_throw=false
51+
cleanup.use_lambda=true
52+
cleanup.use_parentheses_in_expressions=true
53+
cleanup.use_this_for_non_static_field_access=true
54+
cleanup.use_this_for_non_static_field_access_only_if_necessary=true
55+
cleanup.use_this_for_non_static_method_access=true
56+
cleanup.use_this_for_non_static_method_access_only_if_necessary=true
57+
cleanup_profile=_demos
58+
cleanup_settings_version=2
59+
eclipse.preferences.version=1
60+
formatter_profile=_demo settings
61+
formatter_settings_version=14
26.7 KB
Loading
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
2+
<html>
3+
<head>
4+
<title>Insight3D Applet</title>
5+
</head>
6+
<body>
7+
<h1>Insight3D Applet</h1>
8+
9+
<script src="http://www.java.com/js/deployJava.js"></script>
10+
<script>
11+
var attributes = {
12+
id: 'Insight',
13+
code: 'com.agi.InsightApplet',
14+
archive: 'Insight3DApplet.jar',
15+
width: 300,
16+
height:300
17+
};
18+
var parameters = {
19+
jnlp_href: 'Insight3DApplet.jnlp',
20+
separate_jvm: 'true'
21+
};
22+
deployJava.runApplet(attributes, parameters, '1.8');
23+
24+
function viewExtent() {
25+
document.getElementById('Insight').viewExtent(
26+
document.getElementById('west').value,
27+
document.getElementById('south').value,
28+
document.getElementById('east').value,
29+
document.getElementById('north').value);
30+
}
31+
</script>
32+
<br/>
33+
View Extent:
34+
<br/>
35+
West (deg): <input type="text" id="west" value="-96" />
36+
<br/>
37+
South (deg): <input type="text" id="south" value="22" />
38+
<br/>
39+
East (deg): <input type="text" id="east" value="-85" />
40+
<br/>
41+
North (deg): <input type="text" id="north" value="28" />
42+
<br/>
43+
<input type="button" onclick="viewExtent();" value="View Extent" />
44+
</body>
45+
</html>
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<jnlp spec="6.0+" codebase="" href="">
3+
<information>
4+
<title>Insight3DApplet</title>
5+
<vendor>Analytical Graphics, Inc.</vendor>
6+
</information>
7+
8+
<resources arch="amd64">
9+
<j2se version="1.8+" href="http://java.sun.com/products/autodl/j2se" />
10+
<nativelib href="agi.foundation.graphics.native.x64.jar" download="eager" />
11+
</resources>
12+
13+
<resources>
14+
<jar href="Insight3DApplet.jar" main="true" />
15+
16+
<extension name="STK Components" href="STKComponents.jnlp" />
17+
</resources>
18+
19+
<security>
20+
<all-permissions />
21+
</security>
22+
23+
<applet-desc name="InsightApplet" main-class="com.agi.InsightApplet" width="300" height="300" />
24+
25+
<update check="always" />
26+
</jnlp>

Java/Insight3DApplet/README.md

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
# Insight3DApplet
2+
3+
This Java applet demonstrates how to use Insight3D in a web browser, by using a Java Web Start JNLP file to load the native DLLs required by Insight3D, and shows how you can interact with your application from the browser via JavaScript.
4+
5+
![Insight3D Applet](Images/ExampleInsight3DApplet.png)
6+
7+
## Implementation Notes
8+
9+
Because Insight3D has a native DLL library, special steps must be taken to allow an applet to load that native library. [Java Web Start](http://download.oracle.com/javase/tutorial/deployment/webstart/) provides a mechanism to indicate that certain JAR files contain native resources, which will be loaded automatically by the Java runtime before running the applet. These JAR files must be signed.
10+
11+
Java applets can be accessed from the browser via JavaScript. This example includes a very simple demonstration of how you can call a Java method from JavaScript, passing along user input from form elements on the page, and from there calling methods on Insight3D.
12+
13+
This example uses an [Ant](http://ant.apache.org/) build script to demonstrate how to create a JAR containing the Insight3D DLLs, how to sign the JARs with a certificate, and how to create a JNLP file that will load all the parts and run the applet.
14+
15+
## Compilation
16+
17+
To compile this sample applet with Ant:
18+
* Copy your AGI.Foundation.lic file into the src directory.
19+
* Run "ant package".
20+
21+
The ant build script (build.xml) will do the following:
22+
* A JAR file, agi.foundation.graphics.native.x64.jar,
23+
is built containing the Insight3D DLLs, as well as the VC140 runtime DLLs and manifest files.
24+
This is necessary because JNLP requires all native resources to be packaged
25+
into a JAR file to be loaded automatically.
26+
* The native JAR files and the JAR containing the applet code itself
27+
are signed using a certificate. The STK Components JAR files are already
28+
signed by AGI. Details about the keystore used for signing are provided below.
29+
* A JNLP file is created by replacing a placeholder token with the names of
30+
the STK Components JAR files. This avoids making the example dependent on
31+
a particular version of STK Components.
32+
* All JAR files, the JNLP file, and a HTML file loading the applet are placed
33+
in the site directory.
34+
35+
The most reliable way to test the applet is to copy the contents of the site
36+
directory to a location that will be served by a web server, then view the
37+
provided HTML file in your web browser over HTTP.
38+
39+
Note: Depending on your web server, you may need to configure it to serve .jnlp files
40+
with the appropriate MIME type: `application/x-java-jnlp-file`. A web.config file for
41+
Microsoft IIS is included in the site directory.
42+
43+
This applet also demonstrates interacting with the applet through JavaScript.
44+
When you click on the HTML button to View Extent, your browser calls a JavaScript
45+
function, which then calls a viewExtent method in Java on the applet itself,
46+
which then interacts with Insight3D to move the camera.
47+
48+
Keystore Information:
49+
50+
The provided keystore and certificate is for example purposes only. Do not use
51+
this certificate for your own applet! In a real applet, you should obtain a
52+
certificate from a certification authority, and sign your jars using that.
53+
54+
See the Java documentation for more information:
55+
56+
[http://download.oracle.com/javase/tutorial/security/index.html](http://download.oracle.com/javase/tutorial/security/index.html)
57+
58+
This keystore has a password of "keystore", and contains a self-signed
59+
certificate under the alias "cert".
60+
61+
For reference, this keystore was created using the following command:
62+
63+
`keytool -genkey -keystore keystore -storepass keystore -keypass keystore -alias cert -validity 3600 -dname "CN=demo, OU=demo, O=demo, L=demo, ST=PA, C=US" `
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<jnlp spec="6.0+" codebase="" href="">
3+
<information>
4+
<title>STK Components</title>
5+
<vendor>Analytical Graphics, Inc.</vendor>
6+
</information>
7+
8+
<resources>
9+
@LIBRARY_RESOURCES@
10+
</resources>
11+
12+
<security>
13+
<all-permissions />
14+
</security>
15+
16+
<component-desc />
17+
</jnlp>

0 commit comments

Comments
 (0)