From 8777663fc083411346346df58b2d42720fd9954e Mon Sep 17 00:00:00 2001 From: david Date: Sat, 8 Jun 2002 15:54:56 +0000 Subject: [PATCH] Initial draft of a Java client library for FlightGear. --- scripts/java/FGClient/README | 11 + scripts/java/FGClient/build.xml | 49 ++ .../docs/javadoc/allclasses-frame.html | 25 + .../docs/javadoc/deprecated-list.html | 91 +++ .../java/FGClient/docs/javadoc/help-doc.html | 144 +++++ .../java/FGClient/docs/javadoc/index-all.html | 153 +++++ scripts/java/FGClient/docs/javadoc/index.html | 22 + .../flightgear/fgfsclient/FGFSConnection.html | 533 ++++++++++++++++++ .../fgfsclient/class-use/FGFSConnection.html | 93 +++ .../flightgear/fgfsclient/package-frame.html | 26 + .../fgfsclient/package-summary.html | 104 ++++ .../flightgear/fgfsclient/package-tree.html | 99 ++++ .../flightgear/fgfsclient/package-use.html | 93 +++ .../FGClient/docs/javadoc/overview-tree.html | 101 ++++ .../java/FGClient/docs/javadoc/package-list | 1 + .../java/FGClient/docs/javadoc/packages.html | 26 + .../docs/javadoc/serialized-form.html | 91 +++ .../java/FGClient/docs/javadoc/stylesheet.css | 29 + scripts/java/FGClient/fgfsclient.jar | Bin 0 -> 4513 bytes scripts/java/FGClient/src/FGFSDemo.java | 97 ++++ .../flightgear/fgfsclient/FGFSConnection.java | 317 +++++++++++ 21 files changed, 2105 insertions(+) create mode 100644 scripts/java/FGClient/README create mode 100644 scripts/java/FGClient/build.xml create mode 100644 scripts/java/FGClient/docs/javadoc/allclasses-frame.html create mode 100644 scripts/java/FGClient/docs/javadoc/deprecated-list.html create mode 100644 scripts/java/FGClient/docs/javadoc/help-doc.html create mode 100644 scripts/java/FGClient/docs/javadoc/index-all.html create mode 100644 scripts/java/FGClient/docs/javadoc/index.html create mode 100644 scripts/java/FGClient/docs/javadoc/org/flightgear/fgfsclient/FGFSConnection.html create mode 100644 scripts/java/FGClient/docs/javadoc/org/flightgear/fgfsclient/class-use/FGFSConnection.html create mode 100644 scripts/java/FGClient/docs/javadoc/org/flightgear/fgfsclient/package-frame.html create mode 100644 scripts/java/FGClient/docs/javadoc/org/flightgear/fgfsclient/package-summary.html create mode 100644 scripts/java/FGClient/docs/javadoc/org/flightgear/fgfsclient/package-tree.html create mode 100644 scripts/java/FGClient/docs/javadoc/org/flightgear/fgfsclient/package-use.html create mode 100644 scripts/java/FGClient/docs/javadoc/overview-tree.html create mode 100644 scripts/java/FGClient/docs/javadoc/package-list create mode 100644 scripts/java/FGClient/docs/javadoc/packages.html create mode 100644 scripts/java/FGClient/docs/javadoc/serialized-form.html create mode 100644 scripts/java/FGClient/docs/javadoc/stylesheet.css create mode 100644 scripts/java/FGClient/fgfsclient.jar create mode 100644 scripts/java/FGClient/src/FGFSDemo.java create mode 100644 scripts/java/FGClient/src/org/flightgear/fgfsclient/FGFSConnection.java diff --git a/scripts/java/FGClient/README b/scripts/java/FGClient/README new file mode 100644 index 000000000..a8a93077b --- /dev/null +++ b/scripts/java/FGClient/README @@ -0,0 +1,11 @@ +This directory contains a simple, Java network client library for the +FlightGear flight simulator. See the JavaDoc documentation for +org.flightgear.fgfsclient.FGFSConnection for more information. + +There is a simple demo application, FGFSDemo, that you can try like this: + + fgfs --telnet=9000 + java FGFSDemo localhost 9000 + +To rebuild the program, use the Apache ant utility. + diff --git a/scripts/java/FGClient/build.xml b/scripts/java/FGClient/build.xml new file mode 100644 index 000000000..821728615 --- /dev/null +++ b/scripts/java/FGClient/build.xml @@ -0,0 +1,49 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/scripts/java/FGClient/docs/javadoc/allclasses-frame.html b/scripts/java/FGClient/docs/javadoc/allclasses-frame.html new file mode 100644 index 000000000..a38b9e560 --- /dev/null +++ b/scripts/java/FGClient/docs/javadoc/allclasses-frame.html @@ -0,0 +1,25 @@ + + + + + + +All Classes + + + + + +All Classes +
+ + + + + +
FGFSConnection +
+
+ + + diff --git a/scripts/java/FGClient/docs/javadoc/deprecated-list.html b/scripts/java/FGClient/docs/javadoc/deprecated-list.html new file mode 100644 index 000000000..a9e84346c --- /dev/null +++ b/scripts/java/FGClient/docs/javadoc/deprecated-list.html @@ -0,0 +1,91 @@ + + + + + + +: Deprecated List + + + + + + + + + + + + + + + + + +
+ +
+ + +
+
+

+Deprecated API

+
+
+ + + + + + + + + + + + + +
+ +
+ + +
+ + + diff --git a/scripts/java/FGClient/docs/javadoc/help-doc.html b/scripts/java/FGClient/docs/javadoc/help-doc.html new file mode 100644 index 000000000..0df8c2e20 --- /dev/null +++ b/scripts/java/FGClient/docs/javadoc/help-doc.html @@ -0,0 +1,144 @@ + + + + + + +: API Help + + + + + + + + + + + + + + + + + +
+ +
+ + +
+
+

+How This API Document Is Organized

+
+This API (Application Programming Interface) document has pages corresponding to the items in the navigation bar, described as follows.

+Package

+
+ +

+Each package has a page that contains a list of its classes and interfaces, with a summary for each. This page can contain four categories:

+
+

+Class/Interface

+
+ +

+Each class, interface, inner class and inner interface has its own separate page. Each of these pages has three sections consisting of a class/interface description, summary tables, and detailed member descriptions:

+Each summary entry contains the first sentence from the detailed description for that item. The summary entries are alphabetical, while the detailed descriptions are in the order they appear in the source code. This preserves the logical groupings established by the programmer.
+

+Use

+
+Each documented package, class and interface has its own Use page. This page describes what packages, classes, methods, constructors and fields use any part of the given class or package. Given a class or interface A, its Use page includes subclasses of A, fields declared as A, methods that return A, and methods and constructors with parameters of type A. You can access this page by first going to the package, class or interface, then clicking on the "Use" link in the navigation bar.
+

+Tree (Class Hierarchy)

+
+There is a Class Hierarchy page for all packages, plus a hierarchy for each package. Each hierarchy page contains a list of classes and a list of interfaces. The classes are organized by inheritance structure starting with java.lang.Object. The interfaces do not inherit from java.lang.Object. +
+

+Deprecated API

+
+The Deprecated API page lists all of the API that have been deprecated. A deprecated API is not recommended for use, generally due to improvements, and a replacement API is usually given. Deprecated APIs may be removed in future implementations.
+

+Index

+
+The Index contains an alphabetic list of all classes, interfaces, constructors, methods, and fields.
+

+Prev/Next

+These links take you to the next or previous class, interface, package, or related page.

+Frames/No Frames

+These links show and hide the HTML frames. All pages are available with or without frames. +

+

+Serialized Form

+Each serializable or externalizable class has a description of its serialization fields and methods. This information is of interest to re-implementors, not to developers using the API. While there is no link in the navigation bar, you can get to this information by going to any serialized class and clicking "Serialized Form" in the "See also" section of the class description. +

+ + +This help file applies to API documentation generated using the standard doclet. + +
+


+ + + + + + + + + + + + + +
+ +
+ + +
+ + + diff --git a/scripts/java/FGClient/docs/javadoc/index-all.html b/scripts/java/FGClient/docs/javadoc/index-all.html new file mode 100644 index 000000000..5752d86a0 --- /dev/null +++ b/scripts/java/FGClient/docs/javadoc/index-all.html @@ -0,0 +1,153 @@ + + + + + + +: Index + + + + + + + + + + + + + + + + + +
+ +
+ + +C F G O S
+

+C

+
+
close() - +Method in class org.flightgear.fgfsclient.FGFSConnection +
Close the connection to FlightGear. +
+
+

+F

+
+
FGFSConnection - class org.flightgear.fgfsclient.FGFSConnection.
A connection to a running instance of FlightGear.
FGFSConnection(String, int) - +Constructor for class org.flightgear.fgfsclient.FGFSConnection +
Constructor. +
+
+

+G

+
+
get(String) - +Method in class org.flightgear.fgfsclient.FGFSConnection +
Get the raw string value for a property. +
getBoolean(String) - +Method in class org.flightgear.fgfsclient.FGFSConnection +
Get a property value as a boolean. +
getDouble(String) - +Method in class org.flightgear.fgfsclient.FGFSConnection +
Get a property value as a double. +
getFloat(String) - +Method in class org.flightgear.fgfsclient.FGFSConnection +
Get a property value as a float. +
getInt(String) - +Method in class org.flightgear.fgfsclient.FGFSConnection +
Get a property value as an integer. +
getLong(String) - +Method in class org.flightgear.fgfsclient.FGFSConnection +
Get a property value as a long. +
+
+

+O

+
+
org.flightgear.fgfsclient - package org.flightgear.fgfsclient
 
+
+

+S

+
+
set(String, String) - +Method in class org.flightgear.fgfsclient.FGFSConnection +
Set the raw string value for a property. +
setBoolean(String, boolean) - +Method in class org.flightgear.fgfsclient.FGFSConnection +
Set a property value from a boolean. +
setDouble(String, double) - +Method in class org.flightgear.fgfsclient.FGFSConnection +
Set a property value from a double. +
setFloat(String, float) - +Method in class org.flightgear.fgfsclient.FGFSConnection +
Set a property value from a float. +
setInt(String, int) - +Method in class org.flightgear.fgfsclient.FGFSConnection +
Set a property value from an int. +
setLong(String, long) - +Method in class org.flightgear.fgfsclient.FGFSConnection +
Set a property value from a long. +
+
+C F G O S + + + + + + + + + + + + +
+ +
+ + +
+ + + diff --git a/scripts/java/FGClient/docs/javadoc/index.html b/scripts/java/FGClient/docs/javadoc/index.html new file mode 100644 index 000000000..fc69defac --- /dev/null +++ b/scripts/java/FGClient/docs/javadoc/index.html @@ -0,0 +1,22 @@ + + + + + + +Generated Documentation (Untitled) + + + + + + + +<H2> +Frame Alert</H2> + +<P> +This document is designed to be viewed using the frames feature. If you see this message, you are using a non-frame-capable web client. +<BR> +Link to <A HREF="org/flightgear/fgfsclient/package-summary.html">Non-frame version.</A> + diff --git a/scripts/java/FGClient/docs/javadoc/org/flightgear/fgfsclient/FGFSConnection.html b/scripts/java/FGClient/docs/javadoc/org/flightgear/fgfsclient/FGFSConnection.html new file mode 100644 index 000000000..f9f58ebd5 --- /dev/null +++ b/scripts/java/FGClient/docs/javadoc/org/flightgear/fgfsclient/FGFSConnection.html @@ -0,0 +1,533 @@ + + + + + + +: Class FGFSConnection + + + + + + + + + + + + + + + + + + + + + +
+ +
+ + +
+ +

+ +org.flightgear.fgfsclient +
+Class FGFSConnection

+
+java.lang.Object
+  |
+  +--org.flightgear.fgfsclient.FGFSConnection
+
+
+
+
public class FGFSConnection
extends Object
+ +

+A connection to a running instance of FlightGear. + +

This class currently uses the FlightGear telnet interface, + though it may be modified to use a different TCP/IP interface in + the future. Client applications can use this library to examine + and modify internal FlightGear properties.

+ +

To start FlightGear with the telnet server activated, use a + command like this (to listen on port 9000):

+ +
+ fgfs --telnet=9000
+ 
+ +

Then create a connection to FlightGear from your Java client + application:

+ +
+ FGFSConnection fgfs = new FGFSConnection("localhost", 9000);
+ 
+ +

Now you can use the connection to get and set FlightGear + properties:

+ +
+ double altitude = fgfs.getDouble("/position/altitude-ft");
+ fgfs.setDouble("/orientation/heading", 270.0);
+ 
+ +

All methods that communicate directly with FlightGear are + synchronized, since they must work over a single telnet + connection.

+

+


+ +

+ + + + + + + + + + + + + + + + +
+Constructor Summary
FGFSConnection(String host, + int port) + +
+          Constructor.
+  + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
+Method Summary
+ voidclose() + +
+          Close the connection to FlightGear.
+ Stringget(String name) + +
+          Get the raw string value for a property.
+ booleangetBoolean(String name) + +
+          Get a property value as a boolean.
+ doublegetDouble(String name) + +
+          Get a property value as a double.
+ floatgetFloat(String name) + +
+          Get a property value as a float.
+ intgetInt(String name) + +
+          Get a property value as an integer.
+ longgetLong(String name) + +
+          Get a property value as a long.
+ voidset(String name, + String value) + +
+          Set the raw string value for a property.
+ voidsetBoolean(String name, + boolean value) + +
+          Set a property value from a boolean.
+ voidsetDouble(String name, + double value) + +
+          Set a property value from a double.
+ voidsetFloat(String name, + float value) + +
+          Set a property value from a float.
+ voidsetInt(String name, + int value) + +
+          Set a property value from an int.
+ voidsetLong(String name, + long value) + +
+          Set a property value from a long.
+ + + + + + + +
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
+  +

+ + + + + + + + + + + +
+Constructor Detail
+ +

+FGFSConnection

+
+public FGFSConnection(String host,
+                      int port)
+               throws IOException
+
+
Constructor. + +

Create a new connection to a running FlightGear program. + The program must have been started with the --telnet=<port> + command-line option.

+
Parameters:
host - The host name or IP address to connect to.
port - The port number where FlightGear is listening.
Throws:
IOException - If it is not possible to connect to + a FlightGear process.
+
+
+ + + + + + + + +
+Method Detail
+ +

+close

+
+public void close()
+           throws IOException
+
+
Close the connection to FlightGear. + +

The client application should always invoke this method when + it has finished with a connection, to allow cleanup.

+
Throws:
IOException - If there is an error closing the + connection.
+
+
+
+ +

+get

+
+public String get(String name)
+           throws IOException
+
+
Get the raw string value for a property. + +

This is the primitive method for all property lookup; + everything comes in as a string, and is only later converted by + methods like getDouble(String). As a result, if you + need the value as a string anyway, it makes sense to use this + method directly rather than forcing extra conversions.

+
Parameters:
name - The FlightGear property name to look up.
Returns:
The property value as a string (non-existant properties + return the empty string).
Throws:
IOException - If there is an error communicating with + FlightGear or if the connection is lost.
See Also:
getBoolean(String), +getInt(String), +getLong(String), +getFloat(String), +getDouble(String)
+
+
+
+ +

+set

+
+public void set(String name,
+                String value)
+         throws IOException
+
+
Set the raw string value for a property. + +

This is the primitive method for all property modification; + everything goes out as a string, after it has been converted by + methods like setDouble(String,double). As a result, if + you have the value as a string already, it makes sense to use + this method directly rather than forcing extra conversions.

+
Parameters:
name - The FlightGear property name to modify or create.
value - The new value for the property, as a string.
Throws:
IOException - If there is an error communicating with + FlightGear or if the connection is lost.
See Also:
setBoolean(String,boolean), +setInt(String,int), +setLong(String,long), +setFloat(String,float), +setDouble(String,double)
+
+
+
+ +

+getBoolean

+
+public boolean getBoolean(String name)
+                   throws IOException
+
+
Get a property value as a boolean.
+
Parameters:
name - The property name to look up.
Returns:
The property value as a boolean.
See Also:
get(String)
+
+
+
+ +

+getInt

+
+public int getInt(String name)
+           throws IOException
+
+
Get a property value as an integer.
+
Parameters:
name - The property name to look up.
Returns:
The property value as an int.
See Also:
get(String)
+
+
+
+ +

+getLong

+
+public long getLong(String name)
+             throws IOException
+
+
Get a property value as a long.
+
Parameters:
name - The property name to look up.
Returns:
The property value as a long.
See Also:
get(String)
+
+
+
+ +

+getFloat

+
+public float getFloat(String name)
+               throws IOException
+
+
Get a property value as a float.
+
Parameters:
name - The property name to look up.
Returns:
The property value as a float.
See Also:
get(String)
+
+
+
+ +

+getDouble

+
+public double getDouble(String name)
+                 throws IOException
+
+
Get a property value as a double.
+
Parameters:
name - The property name to look up.
Returns:
The property value as a double.
See Also:
get(String)
+
+
+
+ +

+setBoolean

+
+public void setBoolean(String name,
+                       boolean value)
+                throws IOException
+
+
Set a property value from a boolean.
+
Parameters:
name - The property name to create or modify.
value - The new property value as a boolean.
See Also:
set(String,String)
+
+
+
+ +

+setInt

+
+public void setInt(String name,
+                   int value)
+            throws IOException
+
+
Set a property value from an int.
+
Parameters:
name - The property name to create or modify.
value - The new property value as an int.
See Also:
set(String,String)
+
+
+
+ +

+setLong

+
+public void setLong(String name,
+                    long value)
+             throws IOException
+
+
Set a property value from a long.
+
Parameters:
name - The property name to create or modify.
value - The new property value as a long.
See Also:
set(String,String)
+
+
+
+ +

+setFloat

+
+public void setFloat(String name,
+                     float value)
+              throws IOException
+
+
Set a property value from a float.
+
Parameters:
name - The property name to create or modify.
value - The new property value as a float.
See Also:
set(String,String)
+
+
+
+ +

+setDouble

+
+public void setDouble(String name,
+                      double value)
+               throws IOException
+
+
Set a property value from a double.
+
Parameters:
name - The property name to create or modify.
value - The new property value as a double.
See Also:
set(String,String)
+
+
+ +
+ + + + + + + + + + + + + + + + + +
+ +
+ + +
+ + + diff --git a/scripts/java/FGClient/docs/javadoc/org/flightgear/fgfsclient/class-use/FGFSConnection.html b/scripts/java/FGClient/docs/javadoc/org/flightgear/fgfsclient/class-use/FGFSConnection.html new file mode 100644 index 000000000..05335625f --- /dev/null +++ b/scripts/java/FGClient/docs/javadoc/org/flightgear/fgfsclient/class-use/FGFSConnection.html @@ -0,0 +1,93 @@ + + + + + + +: Uses of Class org.flightgear.fgfsclient.FGFSConnection + + + + + + + + + + + + + + + + + +
+ +
+ + +
+
+

+Uses of Class
org.flightgear.fgfsclient.FGFSConnection

+
+No usage of org.flightgear.fgfsclient.FGFSConnection +

+


+ + + + + + + + + + + + + +
+ +
+ + +
+ + + diff --git a/scripts/java/FGClient/docs/javadoc/org/flightgear/fgfsclient/package-frame.html b/scripts/java/FGClient/docs/javadoc/org/flightgear/fgfsclient/package-frame.html new file mode 100644 index 000000000..02cb4ff1a --- /dev/null +++ b/scripts/java/FGClient/docs/javadoc/org/flightgear/fgfsclient/package-frame.html @@ -0,0 +1,26 @@ + + + + + + +: Package org.flightgear.fgfsclient + + + + + +org.flightgear.fgfsclient + + + + +
+Classes  + +
+FGFSConnection
+ + + + diff --git a/scripts/java/FGClient/docs/javadoc/org/flightgear/fgfsclient/package-summary.html b/scripts/java/FGClient/docs/javadoc/org/flightgear/fgfsclient/package-summary.html new file mode 100644 index 000000000..7fee6cd5c --- /dev/null +++ b/scripts/java/FGClient/docs/javadoc/org/flightgear/fgfsclient/package-summary.html @@ -0,0 +1,104 @@ + + + + + + +: Package org.flightgear.fgfsclient + + + + + + + + + + + + + + + + + +
+ +
+ + +
+

+Package org.flightgear.fgfsclient +

+ + + + + + + + + +
+Class Summary
FGFSConnectionA connection to a running instance of FlightGear.
+  + +

+


+ + + + + + + + + + + + + +
+ +
+ + +
+ + + diff --git a/scripts/java/FGClient/docs/javadoc/org/flightgear/fgfsclient/package-tree.html b/scripts/java/FGClient/docs/javadoc/org/flightgear/fgfsclient/package-tree.html new file mode 100644 index 000000000..f83b864fc --- /dev/null +++ b/scripts/java/FGClient/docs/javadoc/org/flightgear/fgfsclient/package-tree.html @@ -0,0 +1,99 @@ + + + + + + +: org.flightgear.fgfsclient Class Hierarchy + + + + + + + + + + + + + + + + + +
+ +
+ + +
+
+

+Hierarchy For Package org.flightgear.fgfsclient +

+
+

+Class Hierarchy +

+ +
+ + + + + + + + + + + + + +
+ +
+ + +
+ + + diff --git a/scripts/java/FGClient/docs/javadoc/org/flightgear/fgfsclient/package-use.html b/scripts/java/FGClient/docs/javadoc/org/flightgear/fgfsclient/package-use.html new file mode 100644 index 000000000..3e1e7a0f4 --- /dev/null +++ b/scripts/java/FGClient/docs/javadoc/org/flightgear/fgfsclient/package-use.html @@ -0,0 +1,93 @@ + + + + + + +: Uses of Package org.flightgear.fgfsclient + + + + + + + + + + + + + + + + + +
+ +
+ + +
+
+

+Uses of Package
org.flightgear.fgfsclient

+
+No usage of org.flightgear.fgfsclient +

+


+ + + + + + + + + + + + + +
+ +
+ + +
+ + + diff --git a/scripts/java/FGClient/docs/javadoc/overview-tree.html b/scripts/java/FGClient/docs/javadoc/overview-tree.html new file mode 100644 index 000000000..c1b77f3e8 --- /dev/null +++ b/scripts/java/FGClient/docs/javadoc/overview-tree.html @@ -0,0 +1,101 @@ + + + + + + +: Class Hierarchy + + + + + + + + + + + + + + + + + +
+ +
+ + +
+
+

+Hierarchy For All Packages

+
+
+
Package Hierarchies:
org.flightgear.fgfsclient
+
+

+Class Hierarchy +

+ +
+ + + + + + + + + + + + + +
+ +
+ + +
+ + + diff --git a/scripts/java/FGClient/docs/javadoc/package-list b/scripts/java/FGClient/docs/javadoc/package-list new file mode 100644 index 000000000..46a6fc5b9 --- /dev/null +++ b/scripts/java/FGClient/docs/javadoc/package-list @@ -0,0 +1 @@ +org.flightgear.fgfsclient diff --git a/scripts/java/FGClient/docs/javadoc/packages.html b/scripts/java/FGClient/docs/javadoc/packages.html new file mode 100644 index 000000000..cf02a1292 --- /dev/null +++ b/scripts/java/FGClient/docs/javadoc/packages.html @@ -0,0 +1,26 @@ + + + + + + + + + + + + +
+ +
+ +
+
+The front page has been relocated.Please see: +
+          Frame version +
+          Non-frame version.
+ + + diff --git a/scripts/java/FGClient/docs/javadoc/serialized-form.html b/scripts/java/FGClient/docs/javadoc/serialized-form.html new file mode 100644 index 000000000..b4b41855a --- /dev/null +++ b/scripts/java/FGClient/docs/javadoc/serialized-form.html @@ -0,0 +1,91 @@ + + + + + + +Serialized Form + + + + + + + + + + + + + + + + + +
+ +
+ + +
+
+

+Serialized Form

+
+
+ + + + + + + + + + + + + +
+ +
+ + +
+ + + diff --git a/scripts/java/FGClient/docs/javadoc/stylesheet.css b/scripts/java/FGClient/docs/javadoc/stylesheet.css new file mode 100644 index 000000000..95f576498 --- /dev/null +++ b/scripts/java/FGClient/docs/javadoc/stylesheet.css @@ -0,0 +1,29 @@ +/* Javadoc style sheet */ + +/* Define colors, fonts and other style attributes here to override the defaults */ + +/* Page background color */ +body { background-color: #FFFFFF } + +/* Table colors */ +.TableHeadingColor { background: #CCCCFF } /* Dark mauve */ +.TableSubHeadingColor { background: #EEEEFF } /* Light mauve */ +.TableRowColor { background: #FFFFFF } /* White */ + +/* Font used in left-hand frame lists */ +.FrameTitleFont { font-size: normal; font-family: normal } +.FrameHeadingFont { font-size: normal; font-family: normal } +.FrameItemFont { font-size: normal; font-family: normal } + +/* Example of smaller, sans-serif font in frames */ +/* .FrameItemFont { font-size: 10pt; font-family: Helvetica, Arial, sans-serif } */ + +/* Navigation bar fonts and colors */ +.NavBarCell1 { background-color:#EEEEFF;}/* Light mauve */ +.NavBarCell1Rev { background-color:#00008B;}/* Dark Blue */ +.NavBarFont1 { font-family: Arial, Helvetica, sans-serif; color:#000000;} +.NavBarFont1Rev { font-family: Arial, Helvetica, sans-serif; color:#FFFFFF;} + +.NavBarCell2 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} +.NavBarCell3 { font-family: Arial, Helvetica, sans-serif; background-color:#FFFFFF;} + diff --git a/scripts/java/FGClient/fgfsclient.jar b/scripts/java/FGClient/fgfsclient.jar new file mode 100644 index 0000000000000000000000000000000000000000..c7b1ccd65cf03b24c52a289c8d28768c2f4b35e9 GIT binary patch literal 4513 zcmaJ_2{@GN+qdt_&=6(c$&Bo~Y-69Y3?o~avG2Q)lwHO&)+}R*ksM1RYY1h@Hl#&J z63W<$D6*Z;9OwJ;?>qlpCd=-5xIi`$;r%3Y3ZJ7P*Q=9tbvX$lE34y7|i}NEUKfY{z2}4 zMfA@Stba?m`FOf}gt)sp2mOoing1{B=I$1Z^zn4{3psJ@cIbbGK?;-<#tA1U^b8CQ ztn~c-{9KVCp8kGdq>poO@NFB<;8!+4O%t9W8+~?lk@zxzok;;z!1nD2qEBaE156|o zLdbiwd1HiCv(1*Ah#g-Usau;vNzn9^7hemZ(N0F# z%Rtyf?w1cT0tzk*F!D8SC_Ef~U+ncaEmyozHma{*s`tR;@_Zwb>2fAc@~Qwbi*ew( z#W^!OYHLaH&4l(mkXNOjsF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Sid8sA zF2!bHKWeMX`LYVhq^&2T&XorB$|bMuTvZq5jUJ!Z=WcHN+-j}}jd+79s+|vth-&Z& z4Vw&vVp|~rq1+HUn*Oc@M?IGk$}$Jb^VrJ~IMJ-H8X~Ao{5-;W)7$7oy@(Dm zxGJO-^O?u3LCNZLkT!2(1#;7oD!&QT0eaB@i8|{o@clDB_01T(d))M;ws-7d+v0T7 z47cs#bjQrV!X87|f=#V_&L2oPZ=3hTW*eMnrGPET?~8(cxv{IuFA_r&2&5lQ(|{YD z$?R#-c{wd~`G%Oz4N>DS<_lLEmL(v4XCBRR716Xey9X59%k)Qbl}n#0nr0fspUPAj z17!IC|?2XYnGd2456D(RPRLM@{jC96GF+Zs~UILu|~jxgqmjl9!5hXB>3- z;MNON>>n2lAqDzCNhuffk8R+Z5036qB(PbDeXKImslpLe)c;5kA^9v1pG#9Ga#`e{ zb~^vVct$9y?>%4fxUIIN3*nX1d$x9MoNqjx7DLZc6ClPg22}^5ibUNalbb;$;>fn% zV#lsD-0))9rzKU^pdY-a`Hre8-w}K@HzlV4lKpo8epFtM2tanAL)uTkagy3EKz`zOCqeR)gBuBw{~|u}f3x#X0R5zGQlC570ZF6ZFJhThis demo connects to a running FlightGear process and displays + * the current altitude, longitude, and latitude in a GUI window, with + * updates every second.

+ * + *

Usage:

+ * + *
+ * fgfs --telnet=9000
+ * java FGFSDemo localhost 9000
+ * 
+ */ +public class FGFSDemo + extends JFrame +{ + + public FGFSDemo (String host, int port) + throws IOException + { + super("FlightGear Client Console"); + + fgfs = new FGFSConnection(host, port); + + getContentPane().setLayout(new FlowLayout()); + + altitudeLabel = new JTextField(fgfs.get("/position/altitude-ft")); + longitudeLabel = new JTextField(fgfs.get("/position/longitude-deg")); + latitudeLabel = new JTextField(fgfs.get("/position/latitude-deg")); + + getContentPane().add(new JLabel("Altitude: ")); + getContentPane().add(altitudeLabel); + getContentPane().add(new JLabel("Longitude: ")); + getContentPane().add(longitudeLabel); + getContentPane().add(new JLabel("Latitude: ")); + getContentPane().add(latitudeLabel); + + new Thread(new Updater()).start(); + } + + private FGFSConnection fgfs; + private JTextField altitudeLabel; + private JTextField longitudeLabel; + private JTextField latitudeLabel; + + public static void main (String args[]) + throws Exception + { + if (args.length != 2) { + System.err.println("Usage: FGFSDemo "); + System.exit(2); + } + FGFSDemo gui = new FGFSDemo(args[0], Integer.parseInt(args[1])); + gui.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + gui.pack(); + gui.show(); + } + + class Updater + implements Runnable + { + + public void run () + { + while (true) { + try { + altitudeLabel.setText(fgfs.get("/position/altitude-ft")); + longitudeLabel.setText(fgfs.get("/position/longitude-deg")); + latitudeLabel.setText(fgfs.get("/position/latitude-deg")); + } catch (IOException e) { + } + try { + Thread.sleep(1000); + } catch (InterruptedException e) { + } + } + } + + } + +} + +// end of FGFSDemo.java diff --git a/scripts/java/FGClient/src/org/flightgear/fgfsclient/FGFSConnection.java b/scripts/java/FGClient/src/org/flightgear/fgfsclient/FGFSConnection.java new file mode 100644 index 000000000..e8f1067e5 --- /dev/null +++ b/scripts/java/FGClient/src/org/flightgear/fgfsclient/FGFSConnection.java @@ -0,0 +1,317 @@ +// FGFSConnection.java - client library for the FlightGear flight simulator. +// Started June 2002 by David Megginson, david@megginson.com +// This library is in the Public Domain and comes with NO WARRANTY. + +package org.flightgear.fgfsclient; + +import java.io.BufferedReader; +import java.io.InputStreamReader; +import java.io.IOException; +import java.io.PrintWriter; + +import java.net.Socket; + + +/** + * A connection to a running instance of FlightGear. + * + *

This class currently uses the FlightGear telnet interface, + * though it may be modified to use a different TCP/IP interface in + * the future. Client applications can use this library to examine + * and modify internal FlightGear properties.

+ * + *

To start FlightGear with the telnet server activated, use a + * command like this (to listen on port 9000):

+ * + *
+ * fgfs --telnet=9000
+ * 
+ * + *

Then create a connection to FlightGear from your Java client + * application:

+ * + *
+ * FGFSConnection fgfs = new FGFSConnection("localhost", 9000);
+ * 
+ * + *

Now you can use the connection to get and set FlightGear + * properties:

+ * + *
+ * double altitude = fgfs.getDouble("/position/altitude-ft");
+ * fgfs.setDouble("/orientation/heading", 270.0);
+ * 
+ * + *

All methods that communicate directly with FlightGear are + * synchronized, since they must work over a single telnet + * connection.

+ */ +public class FGFSConnection +{ + + + //////////////////////////////////////////////////////////////////// + // Constructor. + //////////////////////////////////////////////////////////////////// + + + /** + * Constructor. + * + *

Create a new connection to a running FlightGear program. + * The program must have been started with the --telnet=<port> + * command-line option.

+ * + * @param host The host name or IP address to connect to. + * @param port The port number where FlightGear is listening. + * @exception IOException If it is not possible to connect to + * a FlightGear process. + */ + public FGFSConnection (String host, int port) + throws IOException + { + socket = new Socket(host, port); + in = + new BufferedReader(new InputStreamReader(socket.getInputStream())); + out = new PrintWriter(socket.getOutputStream(), true); + out.println("data\r"); + } + + + + //////////////////////////////////////////////////////////////////// + // Primitive getter and setter. + //////////////////////////////////////////////////////////////////// + + + /** + * Close the connection to FlightGear. + * + *

The client application should always invoke this method when + * it has finished with a connection, to allow cleanup.

+ * + * @exception IOException If there is an error closing the + * connection. + */ + public synchronized void close () + throws IOException + { + out.println("quit\r"); + in.close(); + out.close(); + socket.close(); + } + + + /** + * Get the raw string value for a property. + * + *

This is the primitive method for all property lookup; + * everything comes in as a string, and is only later converted by + * methods like {@link #getDouble(String)}. As a result, if you + * need the value as a string anyway, it makes sense to use this + * method directly rather than forcing extra conversions.

+ * + * @param name The FlightGear property name to look up. + * @return The property value as a string (non-existant properties + * return the empty string). + * @exception IOException If there is an error communicating with + * FlightGear or if the connection is lost. + * @see #getBoolean(String) + * @see #getInt(String) + * @see #getLong(String) + * @see #getFloat(String) + * @see #getDouble(String) + */ + public synchronized String get (String name) + throws IOException + { + out.println("get " + name + '\r'); + return in.readLine(); + } + + + /** + * Set the raw string value for a property. + * + *

This is the primitive method for all property modification; + * everything goes out as a string, after it has been converted by + * methods like {@link #setDouble(String,double)}. As a result, if + * you have the value as a string already, it makes sense to use + * this method directly rather than forcing extra conversions.

+ * + * @param name The FlightGear property name to modify or create. + * @param value The new value for the property, as a string. + * @exception IOException If there is an error communicating with + * FlightGear or if the connection is lost. + * @see #setBoolean(String,boolean) + * @see #setInt(String,int) + * @see #setLong(String,long) + * @see #setFloat(String,float) + * @see #setDouble(String,double) + */ + public synchronized void set (String name, String value) + throws IOException + { + out.println("set " + name + ' ' + value + '\r'); + } + + + + //////////////////////////////////////////////////////////////////// + // Derived getters and setters. + //////////////////////////////////////////////////////////////////// + + + /** + * Get a property value as a boolean. + * + * @param name The property name to look up. + * @return The property value as a boolean. + * @see #get(String) + */ + public boolean getBoolean (String name) + throws IOException + { + return get(name).equals("true"); + } + + + /** + * Get a property value as an integer. + * + * @param name The property name to look up. + * @return The property value as an int. + * @see #get(String) + */ + public int getInt (String name) + throws IOException + { + return Integer.parseInt(get(name)); + } + + + /** + * Get a property value as a long. + * + * @param name The property name to look up. + * @return The property value as a long. + * @see #get(String) + */ + public long getLong (String name) + throws IOException + { + return Long.parseLong(get(name)); + } + + + /** + * Get a property value as a float. + * + * @param name The property name to look up. + * @return The property value as a float. + * @see #get(String) + */ + public float getFloat (String name) + throws IOException + { + return Float.parseFloat(get(name)); + } + + + /** + * Get a property value as a double. + * + * @param name The property name to look up. + * @return The property value as a double. + * @see #get(String) + */ + public double getDouble (String name) + throws IOException + { + return Double.parseDouble(get(name)); + } + + + /** + * Set a property value from a boolean. + * + * @param name The property name to create or modify. + * @param value The new property value as a boolean. + * @see #set(String,String) + */ + public void setBoolean (String name, boolean value) + throws IOException + { + set(name, (value ? "true" : "false")); + } + + + /** + * Set a property value from an int. + * + * @param name The property name to create or modify. + * @param value The new property value as an int. + * @see #set(String,String) + */ + public void setInt (String name, int value) + throws IOException + { + set(name, Integer.toString(value)); + } + + + /** + * Set a property value from a long. + * + * @param name The property name to create or modify. + * @param value The new property value as a long. + * @see #set(String,String) + */ + public void setLong (String name, long value) + throws IOException + { + set(name, Long.toString(value)); + } + + + /** + * Set a property value from a float. + * + * @param name The property name to create or modify. + * @param value The new property value as a float. + * @see #set(String,String) + */ + public void setFloat (String name, float value) + throws IOException + { + set(name, Float.toString(value)); + } + + + /** + * Set a property value from a double. + * + * @param name The property name to create or modify. + * @param value The new property value as a double. + * @see #set(String,String) + */ + public void setDouble (String name, double value) + throws IOException + { + set(name, Double.toString(value)); + } + + + + //////////////////////////////////////////////////////////////////// + // Internal state. + //////////////////////////////////////////////////////////////////// + + private Socket socket; + private BufferedReader in; + private PrintWriter out; + +} + +// end of FGFSConnection.java