WWJava in Eclipse

From World Wind Wiki

Revision as of 21:14, 21 August 2019 by F0urtyfive (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

Contents

[edit] First Impressions

These are my first impressions on running NASA's WorldWind Java 0.2 SDK release in Eclipse. I'm running Vista Business (3gb of RAM), Eclipse 3.3 M7, and Java 1.6.0.

Downloading from Sourceforge is very easy, just unzip and you've got something you can double-click on: worldwind.jar

There is a README that says you should run it from a bat file in order to give the jvm more heap RAM, but that's not necessary just to see if it works.

The NASA team did a good job thinking about ease of entry for this set of source code - click and run for something that works and, as follows, an easy entry into using the SDK with Eclipse.

[edit] Behavior

The mouse wheel zooms in and out, left-click and drag moves around, right-click and drag tilts.

The code has a GeoRSS and a GPX parser built in, as well as NITFS, NMEA, and RPF formats. What's odd, though, is I don't see a LayerSet.xml parser - LayerSet is the Layer object in the .NET version of WorldWind.

[edit] Included

The release comes with 6.25 MB of Blue Marble Next Generation data (Shaded Bathymetry, Tiled, version 1.1 from 05/2004), which makes a nice globe appear the first time you run an app.

The source includes javadoc Java 0.2 SDK API, a README, Design and Coding Guidelines, and the appropriate libraries (JOGL) to run WWJ.

I have some issues with the D&C Guidelines, like the logging policies, but that doesn't really matter - it's an SDK and ready for making apps!

[edit] Using the SDK in Eclipse

Setting up a project from source is always a bit of a headache for any developer, unless you're on the same setup that the source was coded in originally. NASA's Java team used Intellij IDEA for their "0.1" release and if they're using it for this release there's no .ipr included, as there was before, but regardless, it was a very easy 3 step process to get the 0.2 release working in Eclipse. (Click on the images if they appear too small.)

[edit] Step 1: Download and unzip

Grab the code from sourceforge, it's a zip. Unzip it someplace. I unzipped it to c:\software\dev\worldwind.release You'll see that path later.

[edit] Step 2: Start Eclipse and create a New Java Project

Start Eclipse and to to File -> New -> Project. Choose a Java Project.


[edit] Step 3: Point to the existing source code

In the new project wizard, make sure to select "Create project from existing source" and point to the unzipped directory. Then press "Finish."


Done! That was easy. Not like the steps needed for the 0.1 code! Major kudos to the NASA Java team for including JOGL and having a nice directory structure that allows Eclipse to interpret where things are.

Checking the project's settings, we see the libraries have been included:


Here's a shot of Eclipse, running the two demo apps that come with it, worldwinddemo.AWT1Up in the foreground, worldwinddemo.BasicDemo in the background.

To run one of these apps, navigate to src/worldwinddemo/ on the right hand Package Explorer and right click on one of the java classes. In the context menu that appears, go to Run As... and choose Java Application.

There're some interesting things here, first there's a floating placemark (neat), second there's a GML line (also neat) in AWT1Up, and third zooming is all shaky and wierd (bad).


Here's the snippet that produces the icons along the equator, with a 2m meter ones at every 90.

private IconLayer buildIconLayer()
{
   IconLayer layer = new IconLayer();

   for (double lat = 0; lat < 10; lat += 10)
   {
       for (double lon = -180; lon < 180; lon += 10)
       {
           double alt = 0;
           if (lon % 90 == 0)
               alt = 2000000;
           WWIcon icon = new UserFacingIcon("images/32x32-icon-nasa.png",
               new Position(Angle.fromDegrees(lat), Angle.fromDegrees(lon), alt));
           icon.setHighlightScale(1.5);
           icon.setToolTipFont(this.makeToolTipFont());
           icon.setToolTipText(icon.getPath());
           icon.setToolTipTextColor(java.awt.Color.YELLOW);
           layer.addIcon(icon);
       }
   }

   return layer;
}

[edit] Author

G. H. Chinoy

ghcfilter at gmail

Personal tools