comparison src/org/qmul/eecs/c4dm/sia/model/Datapoint.java @ 72:59ebd2ecbcb0

now extends SiaVector
author stevenh
date Fri, 02 Aug 2013 15:37:26 +0100
parents f21eb0fddba2
children
comparison
equal deleted inserted replaced
71:39106212a3c6 72:59ebd2ecbcb0
1 package org.qmul.eecs.c4dm.sia.model; 1 package org.qmul.eecs.c4dm.sia.model;
2 2
3 import java.util.Vector;
4
5 import org.qmul.eecs.c4dm.sia.exceptions.DimensionException;
6 import org.qmul.eecs.c4dm.sia.rdf.Namespaces; 3 import org.qmul.eecs.c4dm.sia.rdf.Namespaces;
7
8 import com.hp.hpl.jena.rdf.model.Resource;
9 4
10 /** 5 /**
11 * @author steven hargreaves 6 * @author steven hargreaves
12 * 7 *
13 */ 8 */
14 public class Datapoint extends NDimensionalObject { 9 public class Datapoint extends SiaVector {
15
16 private Resource resource;
17 private int orderedIndex;
18 10
19 public static final String RESOURCE_URI = Namespaces.SIA_NS_URI + "Datapoint"; 11 public static final String RESOURCE_URI = Namespaces.SIA_NS_URI + "Datapoint";
20 12
21 /**
22 * @return the resource
23 */
24 public Resource getResource() {
25 return resource;
26 }
27
28 /**
29 * @param resource the node to set
30 */
31 public void setResource(Resource resource) {
32 this.resource = resource;
33 }
34
35 /**
36 * @return the orderedIndex
37 */
38 public int getOrderedIndex() {
39 return orderedIndex;
40 }
41
42 /**
43 * @param orderedIndex the orderedIndex to set
44 */
45 public void setOrderedIndex(int orderedIndex) {
46 this.orderedIndex = orderedIndex;
47 }
48
49 /**
50 * @param d
51 * @return
52 */
53 public NDimensionalObject subtract(Datapoint d)
54 {
55 NDimensionalObject nDimObj = new NDimensionalObject();
56 Vector<DimensionValue> dimVals = new Vector<DimensionValue>();
57 int dimensions = d.getDimensionValues().size();
58 DimensionValue dimVal;
59
60 for (int dimension = 1; dimension <= dimensions; dimension++)
61 {
62 dimVal = new DimensionValue();
63 dimVal.setDimension(dimension);
64
65 try {
66 dimVal.setValue(this.getDimensionValue(dimension) - d.getDimensionValue(dimension));
67 } catch (DimensionException e) {
68 e.printStackTrace();
69 System.exit(1);
70 }
71
72 dimVals.add(dimVal);
73 }
74
75 nDimObj.setDimensionValues(dimVals);
76 return nDimObj;
77 }
78
79 } 13 }