Mercurial > hg > semantic-sia
comparison 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 |
comparison
equal
deleted
inserted
replaced
16:6863887e1b70 | 17:f21eb0fddba2 |
---|---|
1 package org.qmul.eecs.c4dm.sia.model; | 1 package org.qmul.eecs.c4dm.sia.model; |
2 | 2 |
3 import org.qmul.eecs.c4dm.sia.SiaMain; | 3 import java.util.Vector; |
4 | |
5 import org.qmul.eecs.c4dm.sia.exceptions.DimensionException; | |
6 import org.qmul.eecs.c4dm.sia.rdf.Namespaces; | |
4 | 7 |
5 import com.hp.hpl.jena.rdf.model.Resource; | 8 import com.hp.hpl.jena.rdf.model.Resource; |
6 | 9 |
10 /** | |
11 * @author steven hargreaves | |
12 * | |
13 */ | |
7 public class Datapoint extends NDimensionalObject { | 14 public class Datapoint extends NDimensionalObject { |
8 | 15 |
9 private Resource resource; | 16 private Resource resource; |
10 private int orderedIndex; | 17 private int orderedIndex; |
11 | 18 |
12 public static final String RESOURCE_URI = SiaMain.SIA_NS_URI + "Datapoint"; | 19 public static final String RESOURCE_URI = Namespaces.SIA_NS_URI + "Datapoint"; |
13 | 20 |
14 /** | 21 /** |
15 * @return the resource | 22 * @return the resource |
16 */ | 23 */ |
17 public Resource getResource() { | 24 public Resource getResource() { |
36 * @param orderedIndex the orderedIndex to set | 43 * @param orderedIndex the orderedIndex to set |
37 */ | 44 */ |
38 public void setOrderedIndex(int orderedIndex) { | 45 public void setOrderedIndex(int orderedIndex) { |
39 this.orderedIndex = orderedIndex; | 46 this.orderedIndex = orderedIndex; |
40 } | 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 } | |
41 | 78 |
42 } | 79 } |