Notes on the GeoServer Workshop

These are the notes I took on the GeoServer workshop at the last gvSIG Conference. Data Directory It is important to change the settings of the geoserver_data_dir in the web.xml file to keep the data each time you restart the application container (like Tomcat). It is also good to check out the other settings as it contains interesting facts such as the type of projections to be used or the size of the cache. There are configurable data on the fly and data not configurable on the fly. ...

March 2, 2012 · 2 min · delawen

Notes of the gvSIG 2.0 workshop

This are the notes that I took over gvSIG 2.0 on the latests Jornadas GvSIG. Pre-requisites Java Eclipse Ant (should) Maven (should) gvSIG (this is recursive :)) The main advantage of gvSIG 2.0 is that you can create a new plugin without knowing how does gvSIG work or having to compile it. We already have a gvSIG installation that deploys the binaries to the workspace. But we don’t have to change the source code. Unless, of course, something doesn’t work (bugs) or we have to add some new functionality to the core. Better if you don’t touch it, ask the developers and they will take care. ...

February 8, 2012 · 4 min · delawen

How to compile gvSIG 2.0

I am proud to share with you the steps to compile gvSIG 2.0, which I discovered thanks to some fellows developers, whom I met thanks to the latests Jornadas GvSIG. Although you can find a full guide on the official documentation, this simple steps will let you customize and compile your own gvSIG2.0 version without much trouble. First, you have to install some basic dependencies: #apt-get install maven2 subversion Next, we create a folder in which we can work: ...

January 8, 2012 · 2 min · delawen

The importance of open data

I’ve been thinking for a while about writing about the importance of open data, but is with the advertising given to Google Map Maker when I really understood the urgency of the matter. Can you imagine a country with so poor geographic data that even the government doesn’t known which cities and towns do they have? How could they invest on roads, literacy, drinking water or even know that there are people who live there? How could they collect taxes or… count votes in elections!? Can you imagine that a battalion of soldiers use maps that are wrong and establish a base in the nearest country? An absurdity that happened recently on the border between [Nicaragua and Costa Rica](https://www. elmundo.es/america/2011/04/19/noticias/1303174548.html), which almost causes an international conflict. ...

April 21, 2011 · 4 min · delawen

High Concurrency

When facing high concurrency applications, we often find a number of generic problems. In this article I will focus on the problems of resources (CPU and memory). For now on, I will focus on the most typical and most direct solutions. When we discover threads and the advantages of parallel processing it can happen that we end up abusing their use. We have a lot of threads (100 ¿? 1000?) simultaneously, and the processor will be jumping from one to another without stopping, not letting them finish, no matter how fast is their real excution. And over time there will be more and more threads only slowing down the process. To the cost of execution of each thread, we must consider also the added cost of creating and destroying threads. It can can become significant when we talk about so many threads at once. ...

July 30, 2010 · 3 min · delawen

Easy map on Java

Sometimes you don’t know where to start when you enter the world of GIS programming. Too many libraries, IDEs, but the truth is, everyone assumes you already have a base and everything become chaos. Something is easy as how to develop a map on Java has scarce documentation. If you have absolutely no idea of GIS, I would recommend you start by the Free book of Free GIS by Victor Olaya. ...

July 16, 2010 · 2 min · delawen

Personalized Event Listeners in Java

Although the Observer pattern is implemented natively in Java, sometimes we need to make an event management that suits better our needs when using event listeners. Some context The problem of event handling is very simple: We have an object that will be changing its state. Without touching its code, we should be able to “hook” to other objects that are pending status changes and act accordingly. This “hook” must be turned on and off dynamically at runtime. ...

July 13, 2010 · 4 min · delawen

How does Memory work on Java

One of the major advantages of Java since its first version was that developers didn’t have to worry about memory, as Java itself was able to keep it clean and free memory automatically. But any good Java developer should know the basics on how Java handles memory to be prevent memory leaks and bottlenecks. To begin with, Java divides memory into two distinct segments: Heap: instances, variables, … Non-Heap/Perm: code, metadata,… As the first step to optimize memory in Java, we should focus on the Heap, as it is what we can “control”. The Heap is divided in two generations depending on their lifetime: ...

July 5, 2010 · 3 min · delawen

FastJTable

Swing JTables of Java by default does not handle frequent updates and a huge number of columns and rows. I created a lighted version of JTable called FastJTable based on the code of the Java Christmas Tree. This implementation is pretty faster when handling huge amounts of data. Consider taking a look at how the memory works if this is your use case. /** * Based on Sun's CTTable (Christmas Tree): * https://java.sun.com/products/jfc/tsc/articles/ChristmasTree/ * * @author marias */ import java.awt.Component; import java.awt.Container; import java.awt.Graphics; import java.awt.Point; import java.awt.Rectangle; import javax.swing.CellRendererPane; import javax.swing.JComponent; import javax.swing.JLabel; import javax.swing.JTable; import javax.swing.JViewport; import javax.swing.plaf.basic.BasicTableUI; import javax.swing.table.TableModel; import org.apache.commons.logging.Log; import org.apache.commons.logging.LogFactory; /** * Based on CTTable from Christmas Tree: * https://java.sun.com/products/jfc/tsc/articles/ChristmasTree/ * * @author marias marias@emergya.es */ public class FastJTable extends JTable { private static final Log log = LogFactory.getLog(FastJTable.class); private static final long serialVersionUID = -3218140266706898440L; private JScrollPane scrollPane; public FastJTable(TableModel model) { super(model); } public void updateUI() { super.updateUI(); setUI(new FastTableUI(this)); } private static class FastTableUI extends BasicTableUI { public FastTableUI(FastJTable table) { super(); installUI(table); } @Override public void installUI(JComponent c) { // Overriden to install our own CellRendererPane super.installUI(c); c.remove(rendererPane); rendererPane = new FastCellRendererPane(); c.add(rendererPane); } } /** * FastCellRendererPane overrides paintComponent to NOT clone the Graphics * passed in and NOT validate the Component passed in. This will NOT work if * the painting code of the Component clobbers the graphics (scales it, * installs a Paint on it...) and will NOT work if the Component needs to be * validated before being painted. */ private static class FastCellRendererPane extends CellRendererPane { private static final long serialVersionUID = 4811773663334451913L; private JViewport viewport; public FastCellRendererPane() { super(); } // Can be ignored, we don't exist in the containment hierarchy. public void repaint() { } @Override public void paintComponent(Graphics g, Component c, Container p, int x, int y, int w, int h, boolean shouldValidate) { try { if (c == null || !isVisible(new Rectangle(x, y, w, h))) { log.trace("No lo pintamos (" + c + ")"); return; } // if (p != null) { // Color oldColor = g.getColor(); // g.setColor(p.getBackground()); // g.fillRect(x, y, w, h); // g.setColor(oldColor); // } if (c.getParent() != this) { this.add(c); } c.setBounds(x, y, w, h); // As we are only interested in using a JLabel as the renderer, // which does nothing in validate we can override this to do // nothing, if you need to support components that can do // layout, // this will need to be commented out, or conditionally // validate. if (!(c instanceof JLabel)) c.validate(); // JComponent jc = (c instanceof JComponent) ? (JComponent) c // : null; // jc.setDoubleBuffered(true); // Don't create a new Graphics, reset the clip and translate // the origin. Rectangle clip = g.getClipBounds(c.getBounds()); g.clipRect(x, y, w, h); g.translate(x, y); c.paint(g); g.translate(-x, -y); g.setClip(clip.x, clip.y, clip.width, clip.height); c.setBounds(-w, -h, 0, 0); } catch (Throwable t) { log.error("Error al pintar el componente de la tabla ", t); } } /** * We only paint the visible parts of the JTable. * @param rectangle visible * @return if it has to be painted on screen */ public boolean isVisible(Rectangle rectangle) { if (viewport == null) return true; Rectangle visRect = viewport.getViewRect(); int xmin = ((Double) rectangle.getMinX()).intValue(); int ymin = ((Double) rectangle.getMinY()).intValue(); int xmax = ((Double) rectangle.getMaxX()).intValue(); int ymax = ((Double) rectangle.getMaxY()).intValue(); return (visRect.contains(new Point(xmin, ymin)) || visRect.contains(new Point(xmax, ymin)) || visRect.contains(new Point(xmin, ymax)) || visRect .contains(new Point(xmax, ymax))); } } }

June 16, 2010 · 3 min · delawen

Decálogo de la Web Social

Si quieres que tu red social funcione, tienes que conocer al público objetivo. Aquí hay algunas guías cínicas para conseguir que tu Web Social funcione. 1.- La gente es egoísta La gente tiende a querer hablar de sí mismos en todo momento y lugar. Nada les interesa más que su propia persona. Ofrecerles un perfil con muchos campos y un botón para subir esas fotos, y también esas otras fotos es algo indispensable. Si la red social no gira en torno a ellos, no les interesará. ...

January 18, 2009 · 2 min · delawen