Mercurial > hg > semantic-sia
changeset 6:7c2d7e0946b3
moved the 'compareTo' method up to the superclass
author | stevenh |
---|---|
date | Tue, 01 Jan 2013 21:15:38 +0000 |
parents | fea6c3dde1c1 |
children | ffd47645ca13 |
files | src/org/qmul/eecs/c4dm/sia/model/Datapoint.java |
diffstat | 1 files changed, 1 insertions(+), 54 deletions(-) [+] |
line wrap: on
line diff
--- a/src/org/qmul/eecs/c4dm/sia/model/Datapoint.java Tue Jan 01 21:13:34 2013 +0000 +++ b/src/org/qmul/eecs/c4dm/sia/model/Datapoint.java Tue Jan 01 21:15:38 2013 +0000 @@ -1,14 +1,10 @@ package org.qmul.eecs.c4dm.sia.model; -import java.util.Iterator; -import java.util.Vector; - import org.qmul.eecs.c4dm.sia.SiaMain; -import org.qmul.eecs.c4dm.sia.exceptions.DimensionException; import com.hp.hpl.jena.rdf.model.Resource; -public class Datapoint extends NDimensionalObject implements Comparable { +public class Datapoint extends NDimensionalObject { private Resource resource; private int orderedIndex; @@ -43,53 +39,4 @@ this.orderedIndex = orderedIndex; } - @Override - public int compareTo(Object o2) { - Datapoint datapoint2 = (Datapoint)o2; - - Vector<DimensionValue> datapoint2DimVals = datapoint2.getDimensionValues(); - - int datapoint2DimSize = datapoint2DimVals.size(); - - if (datapoint2DimSize != this.getDimensionValues().size()) - throw new ClassCastException("Datapoints have an unequal number of dimensions"); - - Iterator<DimensionValue> datapoint1DimValsIter = this.getDimensionValues().iterator(); - Iterator<DimensionValue> datapoint2DimValsIter = datapoint2DimVals.iterator(); - - DimensionValue datapoint1DimVal; - DimensionValue datapoint2DimVal; - - for (int dimension = 1; dimension <= datapoint2DimSize; dimension++) - { - double dimension1 = 0; - try { - dimension1 = this.getDimensionValue(dimension); - } catch (DimensionException e) { - // TODO Auto-generated catch block - System.out.println(e.getMessage()); - e.printStackTrace(); - } - double dimension2 = 0; - try { - dimension2 = datapoint2.getDimensionValue(dimension); - } catch (DimensionException e) { - // TODO Auto-generated catch block - System.out.println(e.getMessage()); - e.printStackTrace(); - } - - if (dimension1 < dimension2) - { - return -1; - } - else if (dimension1 > dimension2) - { - return 1; - } - } - - return 0; - } - }