At this point we will generate a project that will allow us to see a number of gvSIG's basic features. To do this we will create a small map viewer. The requirements might be:

To start making our project we will use the wizard to generate projects that are included in the gvSIG distribution.

The project creation wizard

The gvSIG distribution includes a plugin that displays an assistant for creating development projects on gvSIG. The extension providing this wizard is disabled by default so the first thing we must do is to activate it.


To assist you in the creation of development projects you can find documentation in the Creating our project section of gvSIG's Guide for developers.

To do this, go to the gvSIG preferences panel, and in General, Extensions look for "org.gvsig.mkmvnproject.MakeMavenProjectExtension", and activate the extension. You will need to restart gvSIG to effect the change.

After restarting gvSIG you will notice that the "Tools" menu now has a "Development" sub-menu, which contains a Create new plugin option.

It is important that we supply the following information properly:

Having entered this data, select the Basic plugin with spatial support option.

Click Next to run the script and wait for it to finish generating the project. This can take several minutes depending on your Internet connection and your computer.

During the process of building the project you will be asked:

The script for creating our project, in addition to generating the source code and configuring Maven for use, compiles and displays the first version of the project in the Maven local repository, and also generates the corresponding Eclipse projects so that they can be imported into our workspace.

Project structure

Direct translation from Google translator

Once the wizard has generated our project we can get started by opening Eclipse and selecting as our workspace the folder that was indicated in the wizard. This opens an instance of Eclipse with an empty workspace. The first thing to do is to import the two projects that have been created. For this we will not use the import option.

From the File menu select New->Project... (not java project) and in the dialogue that appears select the General->Project option and click Next. Use "org.gvsig.viewer" as the project name to complete the process. Do the same for the "" project.


You may find it useful to consult information relating to this in the Developer Guide in the gvSIG project structure section and also in Things to consider before developing a plugin.

Let's take a look at the generated code. The projects that have been created are:

We could work with this but since Eclipse is not able to recognise the structure of Maven subprojects it will be much easier to import the child projects as Eclipse projects.

Select the File->import menu option and in the import dialog and select General->Existing Projects Into Workspace and click next. Click "Select root directory" and select the folder "/home/gvsig/workspce/viewer/org.gvsig.viewer/org.gvsig.viewer.lib". In doing this we suggest adding these projects:

These will be selected so just press the button end.

Now repeat the process indicating as "root directory" the following folders:

We have now imported all the projects related to our development into our workspace.

Dependencies between projects

First, let's see what dependencies the assistant has left us with in the org.gvsig.viewer project. Notice the following entry in the dependencyManagement section in the project's pom.xml file:


This imports the dependencies of the various gvSIG libraries so that we don't have to worry about the versions of any of the gvSIG base libraries. As this importing is done in the dependencyManagement section, it is for information purposes only, ie a dependency on these libraries is not set.

If we now look at the dependencies section, we find the entry:


This sets the implementation and test dependencies for all the core libraries of gvSIG so that we won't have to worry about whether all the implementations of the gvSIG APIs are loaded when testing our projects.

In addition we see:


These are fixed build dependencies with the main gvSIG libraries, and are usually required in almost any project that we make with gvSIG.

This configuration of dependencies is found in the main project. Let's now see what dependencies are required for the subprojects.

The Logic Library

The logic part of our development is divided into two projects:

In the API project we find mostly interfaces. These interfaces make up the API of the logic components to be developed. The class model of the example is shown in the following diagram:


Model if the API classes

We have the following entities:

Let's see what we are in the implementation part. Observe that while in the normal API interfaces has been found in the implementation we find classes. Classes that implement the various interfaces that defined in the API. By convention, the implementation of the various interfaces that appear in the API will call the API like prepending the prefix Default.

The class model of implementation for our example is:


Model implementation classes

Let us see the most relevant parts of the implementation.

Presentation libray

Direct translation with Google Translator

As happened with the logic, the presentation also will be divided into two projects, on the one hand and on the other API implementation.

Similar to as with the logic in the presentation, in the draft We only have the API interfaces and abstract classes that define our API. the API of the presenting part is formed by the interface along with manager a set of abstract classes that define the public API of our components, components usually extend to swing JPanel component. These classes are interfaces and abstract because no swing model interfaces for its components. In our example, the only component that is we visual component associated with an apple, the JVisorBlockPanel, which extends from JPanel API level by adding a single method that allows us to obtain the VisorBlock logical component that is associated at any given time.

In the implementation we will find the class DefaultJVisorBlockPanel it receives in its constructor the instance of the VisorBlock to be submitted their data. In general the presentation is not a complication beyond of persons as may be handling swing. The only thing to note is that the presentation should not use anything that is not exposed in the API from our library of logic.

A test application

Direct translation fron google translator

So far we've seen pieces that made up the various loose components that we needed to do our small viewfinder. We will see Now how can we join all those pieces and some more to create a simple viewer let us try everything without having to boot all gvSIG.

To do this, we focus on the org.gvsig.visor.main project. It can find a main class with everything you need to present our map and test our components.

Our program presents a window with a map and a few buttons to zoom or pan tools enable or our information tool on parcels of an apple.


It may be useful to consult the existing literature on the component MapControl This documentation is not has been updated with the changes that have made in that component in version 2 of gvSIG broad lines but continues to provide the same functionality and help better understand the tool.

To do this we will:

Integrating with gvSIG

Direct translation from google Translator

So far we have seen how to create our components, logic and user interface, using gvSIG libraries to access the geographic data or to present as well as a simple way to create a small application that uses them. Let's see now as integrate implementing these features in gvSIG.

If we look at the projects we have in your workspace you will see that there is still one on which we have not worked, . That is where we implemented plugin. Before the plugin code to see a detailed comment. When we described what had to do our extension, we said we had to present a splash customized. Let us first how we can do this.

In the folder "src/main/resources" folder find a theme, and within this one andami-theme.xml file. This file is responsible for specifying the andami framework which splash must dislay as well as must be used a background image in the application MDI or the gvSIG windows icons. Andami, when starts, searchs into the extensions folder anyone wich contains a theme folder and within this file and when it finds it, it uses it. Xml file in our example contains:

      x="270" y="240"
    <!--BackgroundImage path="theme/logo_es.png"/-->
    <!--WallpaperType value="CENTERED"/-->
    <Icon path="$GVSIG_INSTALL/theme/icon.png"/>
  <ApplicationName value="gvSIG 2.0.0"/>

By default routes appear in the file will be interpreted on the location of this file, having a variable GVSIG_INSTALL point to the folder where gvSIG is installed. In the example we see how the tag Splash not indicated path to the file "splash.png" Authors used the files in the folder while the plugin tag Icon variable GVSIG_INSTALL is used to refer the file is in the default theme of Andami.

GvSIG can start and check out the splash indicated in our andami-theme.xml.

Having seen how we can change the splash, we take a look at the extension of our plugin.

Now let's see the code for our plugin. We will see that there are only two classes, VisorExtension and PropertiesOfBlockListener VisorExtension. The class that integrates our functionality in gvSIG is VisorExtension. This class extends the Andami class Extension to integrate with the menus and toolbars, and implements the ExclusiveUIExtension interface to control the visibility of other gvSIG extensions.

To control the visibility of the other areas of gvSIG, the interface ExclusiveUIExtension provides methods:

It is very important delegate isEnabled or isVisible methods of each extension and not return true as you may specify the extent of certain specified conditions; to be visible and active checks herself.

The methods that we find in our class VisorExtension that needs to extend to Extension are:

Basically, we have reviewed as is the integration of our functionality in gvSIG. It remains to be seen PropertiesOfBlockListener class we use to create our tool. The code of the listener is basically similar to that used by our test application.

Distributing our project.

direct translation from google translator*

Once we have our development can be deployed on a run that gvSIG gvSIG and see if it works. Now, normally our work not end there. Typically, we have to do to get these plugins to our users, or even before testers to verify that everything works properly.

With version 2.0 of gvSIG we developed a packaging system that allow us to distribute plugins so that users can install easily from the Add-ons Manager gvSIG (this functionality was ported a gvSIG version 1.11.0).


You can consult the documentation on how to build packages plugin for gvSIG in the section of the development guide, Generate an installation package in paragraph Generation from installation plugin .

The point is how to generate these packages with our plugins. Like with the standard installation of gvSIG had a utility to assist in the creation of our development projects, there is also a utility to generate a plugin packages already installed on gvSIG.

As we had to activate the project creation wizard from the preferences window, activate the same way this utility. We'll go gvSIG preferences panel, and in general, extensions look "", and activate the extension. Once activated we gvSIG restart to take effect changes.

When you reboot gvSIG have the option "Create plugin installation package" in the menu Tools->Development. We will use this tool to build the package Installation of our plugin.

The installation package can be generated directly distribute to our users or to have them reach gvSIG to be exposed in the repository gvSIG supplements and available to users directly from the Add-ons Manager through of the URL displayed by default.

Likewise, for when it is ready the final version of gvSIG 2.0 is expected to have a mechanism that allows to easily include these binary packages in the official distribution gvSIG so that we can have a custom installer for our plugins deliver to our customers.

Cached time 11/21/13 16:29:40 Clear cache and reload