* * PURPOSE: * This class represents an n-dimensional point vector. * @version $Revision: 1.9 $ * * * * COMMENTS: * ************************************************************ */ public class RasPoint { static final String rcsid = "@(#)Package rasj, class RasPoint: $Header: /home/rasdev/CVS-repository/rasdaman/java/rasj/RasPoint.java,v 1.9 2003/12/10 21:04:23 rasdev Exp $"; // array holding the point coordinates private long[] points; // dimensionality of the point private int dimensionality; // number of components initialized already private int streamInitCnt; /** * Constructor getting the dimensionality for stream initialization. * @param dim the dimensionality of this point **/ public RasPoint(int dim) { dimensionality = dim; streamInitCnt = 0; points = new long[dimensionality]; for(int i=0; i< dimensionality; i++) points[i] = 0; } /** * Method for stream initialization of this point. * @param newElement a new dimension that is added to this point **/ public RasPoint stream(long newElement) throws RasStreamInputOverflowException { if(streamInitCnt >= dimensionality) throw new RasStreamInputOverflowException(); points[streamInitCnt++] = newElement; return this; } /** * constructor taking a string representation for this point (for example "[1, 2, 3]"). * @param stringRep the string representation for this point **/ public RasPoint(String stringRep) { dimensionality = 1; streamInitCnt = 0; if(stringRep.trim().charAt(0) != '[') { // error dimensionality = 0; return; } // for parsing the string StringTokenizer strTok = new StringTokenizer(stringRep.trim(), "[,]"); String strCurTok = null; // calculate dimensionality dimensionality = strTok.countTokens(); points = new long[dimensionality]; for(int i=0; i