Android Open Source - zmap Point






From Project

Back to project page zmap.

License

The source code is released under:

GNU Lesser General Public License

If you think the Android project zmap listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.zmap.geom;
//from w  w w . j  a va 2s . c  om
import java.util.Arrays;

public class Point implements IPoint
{
    public Point()
    {
  coord = new double[4];
  set(Double.NaN, Double.NaN, Double.NaN, Double.NaN);
    }

    @Override
    public double getX()
    {
  return coord[X_INDEX];
    }

    @Override
    public double getY()
    {
  return coord[Y_INDEX];
    }

    @Override
    public double getZ()
    {
  return coord[Z_INDEX];
    }

    @Override
    public double getM()
    {
  return coord[M_INDEX];
    }

    @Override
    public double[] get()
    {
        return Arrays.copyOf(coord, coord.length);
    }

    @Override
    public void setX(double x)
    {
  coord[X_INDEX] = x;
    }

    @Override
    public void setY(double y)
    {
  coord[Y_INDEX] = y;
    }

    @Override
    public void setZ(double z)
    {
  coord[Z_INDEX] = z;
    }

    @Override
    public void setM(double m)
    {
  coord[M_INDEX] = m;
    }

    @Override
    public void set(double x, double y)
    {
  set(x, y, getZ(), getM());
    }

    @Override
    public void set(double x, double y, double z)
    {
  set(x, y, z, getM());
    }

    @Override 
    public void set(double x, double y, double z, double m)
    {
  coord[X_INDEX] = x;
  coord[Y_INDEX] = y;
  coord[Z_INDEX] = z;
  coord[M_INDEX] = m;
    }

    @Override
    public void set(double[] newCoords)
    {
        coord[X_INDEX] = newCoords[X_INDEX];
        coord[Y_INDEX] = newCoords[Y_INDEX];
        coord[Z_INDEX] = newCoords[Z_INDEX];
        coord[M_INDEX] = newCoords[M_INDEX];
    }
    
    @Override
    public boolean isEmpty()
    {
  return Double.isNaN(getX()) &&
      Double.isNaN(getY()) &&
      Double.isNaN(getZ()) &&
      Double.isNaN(getM());
    }

    @Override
    public IEnvelope envelope()
    {
        if(isEmpty())
        {
            throw new EmptyGeometryException();
        }
  return new Envelope(getX(), getY(), getX(), getY());
    }

    private double coord[];

    private static final int X_INDEX = 0;
    private static final int Y_INDEX = 1;
    private static final int Z_INDEX = 2;
    private static final int M_INDEX = 3;
}




Java Source Code List

com.zmap.MainActivity.java
com.zmap.geom.EmptyGeometryException.java
com.zmap.geom.Envelope.java
com.zmap.geom.GeometryUtil.java
com.zmap.geom.IEnvelope.java
com.zmap.geom.IGeomCollection.java
com.zmap.geom.IGeomObject.java
com.zmap.geom.ILineOperator.java
com.zmap.geom.IPointCollectionEdit.java
com.zmap.geom.IPointCollection.java
com.zmap.geom.IPoint.java
com.zmap.geom.IPolygon.java
com.zmap.geom.IPolyline.java
com.zmap.geom.IRingCollection.java
com.zmap.geom.IRing.java
com.zmap.geom.IVector.java
com.zmap.geom.InvalidGeometryException.java
com.zmap.geom.PointCollection.java
com.zmap.geom.Point.java
com.zmap.geom.Polyline.java
com.zmap.geom.Ring.java
com.zmap.geom.Vector.java