Index: Point2D.java
===================================================================
--- Point2D.java	(revision 38598)
+++ Point2D.java	(revision 38599)
@@ -22,10 +22,10 @@
 package org.gvsig.fmap.geom.primitive.impl;
 
 import java.awt.Rectangle;
+import java.awt.Shape;
 import java.awt.geom.AffineTransform;
 import java.awt.geom.PathIterator;
 import java.awt.geom.Rectangle2D;
-import java.util.ArrayList;
 
 import org.cresques.cts.ICoordTrans;
 import org.cresques.cts.IProjection;
@@ -43,17 +43,19 @@
 import org.gvsig.fmap.geom.type.GeometryType;
 
 /**
- * Punto 2D.
+ * 2D point implementation.
  * 
  * @author Vicente Caballero Navarro
+ * @author gvSIG team
  */
 public class Point2D extends AbstractPrimitive implements Point, DirectPosition {
+	
+	private static final long serialVersionUID = 1836257305083881299L;
 
     protected static final String COORDINATES_FIELD = "coordinates";
+    protected double x;
+    protected double y;
 
-    private static final long serialVersionUID = 1836257305083881299L;
-    protected double[] coordinates;
-
     /**
      * The constructor with the GeometryType like and argument
      * is used by the {@link GeometryType}{@link #create()} to create the
@@ -63,7 +65,9 @@
      *            The geometry type
      */
     public Point2D(GeometryType geometryType) {
-        this(geometryType, null, null, 0.0, 0.0);
+    	super(geometryType, null, null);
+        this.x = 0.0d;
+        this.y = 0.0d;
     }
 
     /**
@@ -72,28 +76,32 @@
     Point2D(GeometryType geometryType, String id, IProjection projection,
         double x, double y) {
         super(geometryType, id, projection);
-        coordinates = new double[getDimension()];
-        coordinates[0] = x;
-        coordinates[1] = y;
+        this.x = x;
+        this.y = y;
     }
 
     public Point2D(double x, double y) {
         super(TYPES.POINT, SUBTYPES.GEOM2D);
-        coordinates = new double[getDimension()];
-        coordinates[0] = x;
-        coordinates[1] = y;
+        this.x = x;
+        this.y = y;
     }
 
+    public Point2D(GeometryType geometryType, double x, double y) {
+        super(geometryType, null, null);
+        this.x = x;
+        this.y = y;
+    }
+
     public Point2D(int type, int subtype) {
         super(type, subtype);
-        coordinates = new double[getDimension()];
+        this.x = 0.0d;
+        this.y = 0.0d;
     }
 
     public Point2D(java.awt.geom.Point2D point) {
         super(TYPES.POINT, SUBTYPES.GEOM2D);
-        coordinates = new double[getDimension()];
-        coordinates[0] = point.getX();
-        coordinates[1] = point.getY();
+        this.x = point.getX();
+        this.y = point.getY();
     }
 
     /**
@@ -104,242 +112,131 @@
      *            Matriz de transformación.
      */
     public void transform(AffineTransform at) {
+        double[] coordinates = getCoordinates();
         at.transform(coordinates, 0, coordinates, 0, 1);
+        setCoordinates(coordinates);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.awt.Shape#contains(double, double)
-     */
     public boolean contains(double x, double y) {
-        if ((x == coordinates[0]) || (y == coordinates[1])) {
+        if ((this.x == x) || (this.y == y)) {
             return true;
         } else {
             return false;
         }
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.awt.Shape#contains(double, double, double, double)
-     */
     public boolean contains(double x, double y, double w, double h) {
         return false;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.awt.Shape#intersects(double, double, double, double)
-     */
     public boolean intersects(double x, double y, double w, double h) {
         Rectangle2D.Double rAux = new Rectangle2D.Double(x, y, w, h);
 
-        return rAux.contains(coordinates[0], coordinates[1]);
+        return rAux.contains(this.x, this.y);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.awt.Shape#getBounds()
-     */
     public Rectangle getBounds() {
-        return new Rectangle((int) coordinates[0], (int) coordinates[1], 0, 0);
+        return new Rectangle((int) x, (int) y, 0, 0);
     }
 
-    /**
-     * Devuelve la coordenada x del punto.
-     * 
-     * @return Coordenada x.
-     */
     public double getX() {
-        return coordinates[0];
+        return x;
     }
 
-    /**
-     * Devuelve la coordenada y del punto.
-     * 
-     * @return Coordenada y.
-     */
     public double getY() {
-        return coordinates[1];
+        return y;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.awt.Shape#contains(java.awt.geom.Point2D)
-     */
     public boolean contains(java.awt.geom.Point2D p) {
         return false;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.awt.Shape#getBounds2D()
-     */
     public Rectangle2D getBounds2D() {
-        return new Rectangle2D.Double(coordinates[0] - 0.01,
-            coordinates[1] - 0.01, 0.02, 0.02);
+        return new Rectangle2D.Double(x - 0.01, y - 0.01, 0.02, 0.02);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.awt.Shape#contains(java.awt.geom.Rectangle2D)
-     */
     public boolean contains(Rectangle2D r) {
         return false;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.awt.Shape#intersects(java.awt.geom.Rectangle2D)
-     */
     public boolean intersects(Rectangle2D r) {
-        return r.contains(coordinates[0], coordinates[1]);
+        return r.contains(x, y);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.awt.Shape#getPathIterator(java.awt.geom.AffineTransform)
-     */
+    public Shape getShape(AffineTransform affineTransform) {
+        return this;
+    }
+
     public PathIterator getPathIterator(AffineTransform at) {
         return new PointIterator(getPoint2D(), at);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see java.awt.Shape#getPathIterator(java.awt.geom.AffineTransform,
-     * double)
-     */
     public PathIterator getPathIterator(AffineTransform at, double flatness) {
         return new PointIterator(getPoint2D(), at);
     }
 
     private java.awt.geom.Point2D getPoint2D() {
-        return new java.awt.geom.Point2D.Double(coordinates[0], coordinates[1]);
+        return new java.awt.geom.Point2D.Double(x, y);
     }
 
-    /**
-     * @see org.gvsig.fmap.geom.primitive.FShape#getShapeType()
-     */
     public int getShapeType() {
         return TYPES.POINT;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.iver.cit.gvsig.fmap.core.FShape#cloneFShape()
-     */
     public FShape cloneFShape() {
-        return new Point2D(getGeometryType(), id, projection, coordinates[0],
-            coordinates[1]);
+        return new Point2D(getGeometryType(), id, projection, x, y);
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see
-     * com.iver.cit.gvsig.fmap.core.FShape#reProject(org.cresques.cts.ICoordTrans
-     * )
-     */
     public void reProject(ICoordTrans ct) {
         java.awt.geom.Point2D p = getPoint2D();
         p = ct.convert(p, p);
-        coordinates[0] = p.getX();
-        coordinates[1] = p.getY();
+        this.x = p.getX();
+        this.y = p.getY();
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.iver.cit.gvsig.fmap.core.FShape#getStretchingHandlers()
-     */
     public Handler[] getStretchingHandlers() {
-        ArrayList handlers = new ArrayList();
-        handlers.add(new PointHandler(0, coordinates[0], coordinates[1]));
-        return (Handler[]) handlers.toArray(new Handler[0]);
+        return new Handler[] { new PointHandler(0, x, y, this) };
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see com.iver.cit.gvsig.fmap.core.FShape#getSelectHandlers()
-     */
     public Handler[] getSelectHandlers() {
-        ArrayList handlers = new ArrayList();
-        handlers.add(new PointHandler(0, coordinates[0], coordinates[1]));
-        return (Handler[]) handlers.toArray(new Handler[0]);
+        return new Handler[] { new PointHandler(0, x, y, this) };
     }
 
     /**
-     * DOCUMENT ME!
      * 
      * @author Vicente Caballero Navarro
+     * @author gvSIG team
      */
     class PointHandler extends AbstractHandler implements FinalHandler {
 
-        /**
-         * Crea un nuevo PointHandler.
-         * 
-         * @param x
-         *            DOCUMENT ME!
-         * @param y
-         *            DOCUMENT ME!
-         */
-        public PointHandler(int i, double x, double y) {
+        private final Point gvSIGPoint;
+
+        public PointHandler(int i, double x, double y, Point gvSIGPoint) {
+            this.gvSIGPoint = gvSIGPoint;
             point = new java.awt.geom.Point2D.Double(x, y);
             index = i;
         }
 
-        /**
-         * DOCUMENT ME!
-         * 
-         * @param x
-         *            DOCUMENT ME!
-         * @param y
-         *            DOCUMENT ME!
-         * 
-         * @return DOCUMENT ME!
-         */
-        public void move(double x, double y) {
-            coordinates[0] = coordinates[0] + x;
-            coordinates[1] = coordinates[1] + y;
+        public void move(double movex, double movey) {
+            gvSIGPoint.setX(gvSIGPoint.getX() + movex);
+            gvSIGPoint.setY(gvSIGPoint.getY() + movey);
         }
 
-        /**
-         * @see org.gvsig.fmap.geom.handler.Handler#set(double, double)
-         */
-        public void set(double x, double y) {
-            coordinates[0] = x;
-            coordinates[1] = y;
+        public void set(double setx, double sety) {
+            gvSIGPoint.setX(setx);
+            gvSIGPoint.setY(sety);
         }
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.gvsig.geometries.iso.GM_Object#coordinateDimension()
-     */
     public int getDimension() {
         return 2;
     }
 
     public Envelope getEnvelope() {
-        return new Envelope2D(coordinates[0] - 0.01, coordinates[1] - 0.01,
-            coordinates[0] + 0.02, coordinates[1] + 0.02);
+        return new Envelope2D(x - 0.01, y - 0.01, x + 0.02, y + 0.02);
     }
 
     public GeneralPathX getGeneralPath() {
-        // TODO Auto-generated method stub
         return null;
     }
 
@@ -348,10 +245,10 @@
     }
 
     public double getOrdinate(int dim) {
-        if (dim == 0) {
+        if (dim == Geometry.DIMENSIONS.X) {
             return getX();
         } else
-            if (dim == 1) {
+            if (dim == Geometry.DIMENSIONS.Y) {
                 return getY();
             } else {
                 return 0;
@@ -373,72 +270,63 @@
 
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.gvsig.fmap.geom.primitive.Point#getCoordinates()
-     */
     public double[] getCoordinates() {
-        return coordinates;
+        return new double[] { x, y };
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.gvsig.fmap.geom.primitive.Point#getDoordinateAt(int)
-     */
     public double getCoordinateAt(int dimension) {
-        return coordinates[dimension];
+        switch (dimension) {
+        case Geometry.DIMENSIONS.X:
+            return x;
+        case Geometry.DIMENSIONS.Y:
+            return y;
+        default:
+            throw new ArrayIndexOutOfBoundsException(dimension);
+        }
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.gvsig.fmap.geom.primitive.Point#setCoordinateAt(int, double)
-     */
     public void setCoordinateAt(int dimension, double value) {
-        coordinates[dimension] = value;
+        switch (dimension) {
+        case Geometry.DIMENSIONS.X:
+            this.x = value;
+            break;
+        case Geometry.DIMENSIONS.Y:
+            this.y = value;
+            break;
+        default:
+            throw new ArrayIndexOutOfBoundsException(dimension);
+        }
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.gvsig.fmap.geom.primitive.Point#setCoordinates(double[])
-     */
     public void setCoordinates(double[] values) {
-        coordinates = values;
+        this.x = values[Geometry.DIMENSIONS.X];
+        this.y = values[Geometry.DIMENSIONS.Y];
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.gvsig.fmap.geom.primitive.Point#setX(double)
-     */
     public void setX(double x) {
-        coordinates[0] = x;
+        this.x = x;
     }
 
-    /*
-     * (non-Javadoc)
-     * 
-     * @see org.gvsig.fmap.geom.primitive.Point#setY(double)
-     */
     public void setY(double y) {
-        coordinates[1] = y;
+        this.y = y;
     }
 
     public String toString() {
         StringBuffer buffer = new StringBuffer();
-        buffer.append("Point2D(");
-        toStringCoordinates(buffer);
+        double[] coordinates = getCoordinates();
+        buffer.append(getFullTypeName()).append("(").append(coordinates[0]);
+        for (int i = 1; i < coordinates.length; i++) {
+            buffer.append(",").append(coordinates[i]);
+        }
         buffer.append(")");
         return buffer.toString();
     }
 
-    protected void toStringCoordinates(StringBuffer buffer) {
-        buffer.append(coordinates[0]);
-        for (int i = 1; i < coordinates.length; i++) {
-            buffer.append(",").append(coordinates[i]);
-        }
+    protected String getFullTypeName() {
+        return "Point2D";
     }
+    
+    public int getType() {
+        return TYPES.POINT;
+    }
 }
