Wednesday Dec 05, 2012

Selecting Items in a GeoToolkit Driven Map

When you take a look at all the tools provided by GeoToolkit, you'll be quite impressed. For example, within the US map shown in yesterday's blog entry, you can drill down into individual states by selecting them via the mouse, as shown below:

With that, the basis of a more complex application is laid, since all the map-related functionality is handed to you out of the box.

The sample referred to yesterday has been updated, if you check it out and run it (assuming you've taken the additional steps mentioned yesterday), you'll see the above.

Tuesday Dec 04, 2012

GeoToolkit Demo Embedded in an Application Framework via Maven

As a follow on to yesterday's blog entry, here's the equivalent starter application for GeoToolkit (also known as Geotk) on the NetBeans Platform, which ends up looking like this:

The above is a border.shp file I found on-line, while here's a USA states shape file rendered in the application:

Note that the navigation bar is also included, though that could later be migrated into the menu bar of the NetBeans Platform. 

Download the Maven based NetBeans Platform application with GeoToolkit integration here:

It was quite tricky getting this sample together, parts of it, especially the installer, which creates the database, comes from the Puzzle GIS project, while the files come from on-line locations, with the JAI-related dependencies providing problems of their own. I was able to solve the vendorName==null problem by downloading the jai_imageio.jar JAR found here and replacing the equivalent JAR in my POM with that one.

What you now have above is definitely a starting point giving you the basic Maven structure needed for getting started with GeoToolkit in the context of all the services and components provided by the NetBeans Platform. 

Many thanks to Johann Sorel for his patience and help. 

Monday Dec 03, 2012

GeoTools Demo Embedded in an Application Framework via Maven

GeoTools 8.4 was very recently released, according to its active blog, and to celebrate here's a starting point for working with GeoTools on the NetBeans Platform:

The sources of the above are below, as a Maven project, so this project can be used in any IDE or command line:

Though quite dated, the GeoTools NetBeans Quick Start is very helpful, especially since it used Maven too, but not the NetBeans Platform, unlike the above sample. From the point of view of NetBeans Platform developers, the GeoTools JMapPane class is very useful, providing the integration point between GeoTools and the rest of the NetBeans Platform application.

Being integrated into the NetBeans Platform means that a host of standard features are now available to the GeoTools features, e.g., print functionality, which only requires a runtime dependency on the NetBeans Print API, together with the "print.printable" client property put into constructor of the TopComponent:

By the way, I've spent some time now and again being confused about the difference between GeoTools and GeoToolkit. Here's an interesting starting point to beginning to understand the differences and history between them. Soon I'd like to have an example similar for the above for GeoToolkit.

Sunday Dec 02, 2012

Dark NetBeans

Let's make NetBeans IDE look like this. Not saying it's a nice color or anything, just that it's possible to do so:

I changed the coloring in the Java editor by going to Tools | Options, then chose "Fonts & Colors", then selected the "Norway Today" profile and changed the background setting to Dark Gray.

Next, I put this themes.xml file into the "config" folder of the NetBeans IDE user directory, which you can identify as such by going to Help | About in the IDE. Go to the exact location defined by "User directory" in Help | About, and then go to the "config" folder within that folder:

The "config" folder of the user directory is the readable/writable root of the NetBeans IDE virtual filesystem. If a themes.xml file is found there, it is used, as described here.

Then, in netbeans.conf file, which is not in the NetBeans user directory but in the NetBeans installation directory, within its "etc" folder, I added the following to "netbeans_default_options":

-J-Dnetbeans.useTheme=true --laf Metal

The first of these enables usage of the themes.xml file, i.e., it notifies NetBeans IDE at startup to load the themes.xml file and to apply the content to the relevant UI components, while the second is needed because most/all of the themes only work if you're using the Metal Look and Feel.

Note: I must add that in most cases, whatever it is you're trying to achieve via a themes.xml file can probably be achieved in a different, and better, way. The themes.xml mechanism has been there forever, but is not actively supported or tested, though it may work for the specific thing you're trying to do anyway. For example, if you're trying to change the background color of a TopComponent, use the paintComponent method of the TopComponent instead of using a themes.xml file.


Geertjan Wielenga (@geertjanw) is a Principal Product Manager in the Oracle Developer Tools group living & working in Amsterdam. He is a Java technology enthusiast, evangelist, trainer, speaker, and writer. He blogs here daily.

The focus of this blog is mostly on NetBeans (a development tool primarily for Java programmers), with an occasional reference to NetBeans, and sometimes diverging to topics relating to NetBeans. And then there are days when NetBeans is mentioned, just for a change.


« December 2012 »