A Curious Animal
Bla, bla, bla, ..., (evolution) , ..., blog, blog, blog, ...
Bla, bla, bla, ..., (evolution) , ..., blog, blog, blog, ...
Thu, 15 Oct, 2009
This post is a mini tutorial on how to create an application based on NetBeans Platform that uses the WorldWind Java virtual globe.
Before to continue, you need to have some knowledge about NetBeans Platform, WWJ and JOGL.
NetBeans Platform, similar to Eclipse RCP, is a platform which offers a set of basic functions and functionallities that are common in almost all project. The most clear examples of applications developed with these platforms are NetBeans IDE and Eclipse IDE themselves.
In the case of NetBeans Platform some features that likes me are:
WordlWind Java is a Java API to create and work with a virtual globe, something common on these days and not so easy to implement.
In contrast to WorldWind .NET which is a desktop application, WWJ is only an API, a set of classes you can use to create your own based application.
One impotant thing is WWJ works thanks to JOGL (Java binding for OpenGL API), which is a Java API to work with OpenGL and that uses a native library implementation depending on your system.
Nice question. Ok, if we can say there is any problem it will be: how to create a NetBeans module which includes the JOGL JAR files and also the native libraries so my application will be portable?
Follow the next steps and you will see there is not problem to achieve that.
Here is the list of software and versions I'm using for this example:
Install NetBeans if you don't have installed. Download WWJ and JOGL and uncompress it at some place.
Ok next is the important part of this article. The basic idea is to create a new NetBeans Platform application with two library modules, containing required JAR files for JOGL and WorldWindJava:
Select the worlwind.jar file from WWJ folder. This will create a module into your NB platform application with the next folder structure:
Select the jogl.jar and gluegen.jar files from JOGL folder. In addition to the previous step, here we need to include the native libraries JOGL needs to run. To do that you must to create a folder called release/modules/lib and copy the native libraries.
In the above image you can se the *.so files which corresponds only to the Linux native libraries. To make your application portable to other systems you must need to copy here the required *.dll or any other files.
This module will contain the code to create a TopComponent window which will show the WWJ virtual globe:
What you need to do now is to set the dependecies among the modules. WWJ module depends on JOGL one and your previous normal module will depend on WWJ and JOGL, because it will show a window with the virtual globe.
Right-click on the module name and select New > Window Component. In the next wizard step select for Position the value editor. Press next and select a name for your TopComponent class (and an icon if desired).
Open the code of your TopComponent and in the init() method add the next lines:
Model model = (Model) WorldWind.createConfigurationComponent(AVKey.MODEL_CLASS_NAME);
WorldWindowGLCanvas wwj = new WorldWindowGLCanvas();
wwj.setModel(model);
setLayout(new BorderLayout());
add(wwj, BorderLayout.CENTER);
You will need to import the required packages from WWJ module, which you must set as a dependency previously.
If you have followed the above steps the result you must get must be something similar to:
In addition and the benefit of use these approach is your applciation, once build a ZIP distribution, will run on different machines thanks to the native libraries attached in the 'lib' folder.
Please, feel free to set any comments you think, ideas and suggestions.
Fri, 2 Oct, 2009
I would like to have written this post some time ago but time is not something I have in exces.
This post starts when my friend Johann let me know the creation of the GeoToolkit project, a fork of GeoTools, started by one of the originals GeoTools authors. Take a look at project's history to know more details about the reasons.
Next is a simple example showing how to reproject coordinates from WSG84(EPSG:4326) to EPSG:3068 that, for those interested, I used in a program to render CityGML files in a Java 3D viewer called pTolemy3D.
public static boolean translate(GeneralDirectPosition source, GeneralDirectPosition target) {
CRSAuthorityFactory factory = AuthorityFactoryFinder.getCRSAuthorityFactory("EPSG", null);
try {
ProjectedCRS projSource = factory.createProjectedCRS("3068");
GeodeticCRS projTarget = factory.createGeographicCRS("4326");
// NOTE: This is another way to create the right projection:
// ProjectedCRS proj = (ProjectedCRS) CRS.decode("EPSG:3068");
// System.out.println("Orig: " + projSource);
// System.out.println("Target: " + projTarget);
MathTransform transform = CRS.findMathTransform(projSource, projTarget);
// System.out.println("Transform: " + transform);
try {
transform.transform(source, target);
return true;
// System.out.println("Point Source: " + psource);
// System.out.println("Point Target: " + ptarget);
} catch (MismatchedDimensionException ex) {
Logger.getLogger(GeoUtil.class.getName()).log(Level.SEVERE, null, ex);
} catch (TransformException ex) {
Logger.getLogger(GeoUtil.class.getName()).log(Level.SEVERE, null, ex);
}
} catch (NoSuchAuthorityCodeException ex) {
Logger.getLogger(GeoUtil.class.getName()).log(Level.SEVERE, null, ex);
} catch (FactoryException ex) {
Logger.getLogger(GeoUtil.class.getName()).log(Level.SEVERE, null, ex);
}
return false;
}
Not so much, but hope it will be useful for someone and hope more users start to use GeoToolkit.
Sun, 13 Sep, 2009
If like me, you need to parse some text using regular expressions and it must be done in a casi insensitive way, here is the trick you are looking for.
If you use the Pattern class approach, then add the Pattern.CASE_INSENSITIVE flag:
Pattern p = Pattern.compile("YOUR_REGEX", Pattern.CASE_INSENSITIVE);
If you prefer to use the String.matches() method, then use the ?i flag in the regular expression:
"XYZxyz".matches("(?i)[a-z]+")
I want to note I found this help on: http://blogs.sun.com/xuemingshen/entry/case_insensitive_matching_in_java.
Thu, 10 Sep, 2009
Recently I started working with Jetty. I have never used it, always working with Tomcat and my dear GlassFish.
One of my first problems with Jetty was about the symbolic links in Linux. Usually, while developing, I like to have my code organized in some directories and my servers in others. Then I create a simlink from the webapps Jetty's folder to my project folder. But that strategy fails initially in Jetty.
Taking a look in the FAQ pages found here and here, you can read that:
Jetty by defaults runs in a mode where all file accesses are checked for aliases, such as case insensitivity, short names, symbolic links and extra characters (Eg %00). If a resource is an alias, then it is treated as not found.
There are, or at least I know two solutions.
java -Dorg.mortbay.util.FileResource.checkAliases=False -jar start.jar
default
org.mortbay.jetty.servlet.DefaultServlet
. . .
aliases
true
. . .
Fri, 8 May, 2009
Some days ago I read a post related to the citygml4j project. As its web page says:
citygml4j is a Java class library and API for facilitating work with the City Geography Markup Language (CityGML). citygml4j makes it easy to read, process, and write CityGML datasets, and to develop CityGML-aware software applications.
A couple of days ago I downloaded the binary package and try to execute some samples. Unfortunately it was compiled using Java6 and I was using Java.5 because I need it for my current project.
I wrote an email to Claus Nagel, the project manager, talking about my "problem" and (wow) a couple of hours after, Claus has published a new binary package ready to use with Java1.5.
I only have congratulation words for you Claus ;)
Wed, 6 May, 2009
JPA is the ORM specification which allows us to work in the same way independently of the ORM underline engine: hibernate, toplink, JDO, etc.
The most important concept is the entity, but around it there are a lot of other concepts like PersistenceContext, PersistenceUnits, EntityManager, etc.
Here is a brief summary of this concepts and the actions you can make over an entity:
You can think about the PersistenceContext as a kind of cache of the database. The basic actions you can make over an entity are:
Sat, 11 Apr, 2009
On this post I try to summarize, from my personal point of view and experience, the reason I like Java on the server side. The point of view isn't from the developer side but from a system administrator role.
Consider too, the intention of this post isn't to create a flame war among Java, PHP, ASP or any other technology. Simply is a list of pros about Java on the server side and, to be fair, I think some day I would need to write a list of cons.
Usually I work on Linux servers. The steps a follow to install Java are:
In the same way you can update your Java version downloading the new JDK or JRE package, uncrompressing it and updating the previous simlink.
Recent comments
7 weeks 3 days ago
14 weeks 5 days ago
1 year 14 hours ago
1 year 20 weeks ago
1 year 20 weeks ago