Mercurial > hg > semantic-sia
view src/org/qmul/eecs/c4dm/sia/model/Datapoint.java @ 17:f21eb0fddba2
organized imports
added the "subtract" method
use the new "Namespaces" class when creating String RESOURCE_URI
author | stevenh |
---|---|
date | Tue, 08 Jan 2013 18:33:10 +0000 |
parents | 7c2d7e0946b3 |
children | 59ebd2ecbcb0 |
line wrap: on
line source
package org.qmul.eecs.c4dm.sia.model; import java.util.Vector; import org.qmul.eecs.c4dm.sia.exceptions.DimensionException; import org.qmul.eecs.c4dm.sia.rdf.Namespaces; import com.hp.hpl.jena.rdf.model.Resource; /** * @author steven hargreaves * */ public class Datapoint extends NDimensionalObject { private Resource resource; private int orderedIndex; public static final String RESOURCE_URI = Namespaces.SIA_NS_URI + "Datapoint"; /** * @return the resource */ public Resource getResource() { return resource; } /** * @param resource the node to set */ public void setResource(Resource resource) { this.resource = resource; } /** * @return the orderedIndex */ public int getOrderedIndex() { return orderedIndex; } /** * @param orderedIndex the orderedIndex to set */ public void setOrderedIndex(int orderedIndex) { this.orderedIndex = orderedIndex; } /** * @param d * @return */ public NDimensionalObject subtract(Datapoint d) { NDimensionalObject nDimObj = new NDimensionalObject(); Vector<DimensionValue> dimVals = new Vector<DimensionValue>(); int dimensions = d.getDimensionValues().size(); DimensionValue dimVal; for (int dimension = 1; dimension <= dimensions; dimension++) { dimVal = new DimensionValue(); dimVal.setDimension(dimension); try { dimVal.setValue(this.getDimensionValue(dimension) - d.getDimensionValue(dimension)); } catch (DimensionException e) { e.printStackTrace(); System.exit(1); } dimVals.add(dimVal); } nDimObj.setDimensionValues(dimVals); return nDimObj; } }