# HG changeset patch # User stevenh # Date 1357074938 0 # Node ID 7c2d7e0946b34adf790cc647f1e2ff255770c43b # Parent fea6c3dde1c1a8574058c1d9a4a0d62c4902ef4b moved the 'compareTo' method up to the superclass diff -r fea6c3dde1c1 -r 7c2d7e0946b3 src/org/qmul/eecs/c4dm/sia/model/Datapoint.java --- 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 datapoint2DimVals = datapoint2.getDimensionValues(); - - int datapoint2DimSize = datapoint2DimVals.size(); - - if (datapoint2DimSize != this.getDimensionValues().size()) - throw new ClassCastException("Datapoints have an unequal number of dimensions"); - - Iterator datapoint1DimValsIter = this.getDimensionValues().iterator(); - Iterator 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; - } - }