Commit a9127d71 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

StructuralState comparator updated to compare z index

parent e457d714
......@@ -6,25 +6,19 @@ import org.apache.logging.log4j.Logger;
import lcsb.mapviewer.common.Comparator;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.common.comparator.DoubleComparator;
import lcsb.mapviewer.common.comparator.IntegerComparator;
import lcsb.mapviewer.common.comparator.PointComparator;
import lcsb.mapviewer.common.comparator.StringComparator;
import lcsb.mapviewer.model.map.MiriamData;
/**
* Comparator of {@link MiriamData} object.
*
* @author Piotr Gawron
*
*/
public class StructuralStateComparator extends Comparator<StructuralState> {
/**
* Epsilon value used for comparison of doubles.
*/
private double epsilon;
private static Logger logger = LogManager.getLogger();
private final StringComparator stringComparator;
private final PointComparator pointComparator;
private final DoubleComparator doubleComparator;
private final IntegerComparator integerComparator;
/**
* Default constructor.
*/
......@@ -34,22 +28,22 @@ public class StructuralStateComparator extends Comparator<StructuralState> {
public StructuralStateComparator(final double epsilon) {
super(StructuralState.class);
this.epsilon = epsilon;
stringComparator = new StringComparator();
pointComparator = new PointComparator(epsilon);
doubleComparator = new DoubleComparator();
integerComparator = new IntegerComparator();
}
@Override
protected int internalCompare(final StructuralState arg0, final StructuralState arg1) {
StringComparator stringComparator = new StringComparator();
if (stringComparator.compare(arg0.getValue(), arg1.getValue()) != 0) {
return stringComparator.compare(arg0.getValue(), arg1.getValue());
}
PointComparator pointComparator = new PointComparator(epsilon);
if (pointComparator.compare(arg0.getPosition(), arg1.getPosition()) != 0) {
logger.debug("position different: " + arg0.getPosition() + ", " + arg1.getPosition());
return pointComparator.compare(arg0.getPosition(), arg1.getPosition());
}
DoubleComparator doubleComparator = new DoubleComparator();
if (doubleComparator.compare(arg0.getWidth(), arg1.getWidth()) != 0) {
logger.debug("width different: " + arg0.getWidth() + ", " + arg1.getWidth());
return doubleComparator.compare(arg0.getWidth(), arg1.getWidth());
......@@ -59,6 +53,11 @@ public class StructuralStateComparator extends Comparator<StructuralState> {
return doubleComparator.compare(arg0.getHeight(), arg1.getHeight());
}
if (integerComparator.compare(arg0.getZ(), arg1.getZ()) != 0) {
logger.debug("z different: " + arg0.getZ() + ", " + arg1.getZ());
return integerComparator.compare(arg0.getZ(), arg1.getZ());
}
return 0;
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment