use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.
the class TestBoundingBox method testIntersection2.
/**
* Test the intersection of two bounding boxes
*/
@Test(timeout = 60000)
public void testIntersection2() {
final BoundingBox boundingBox = new BoundingBox(1d, 3d, 3d, 7d);
Assert.assertEquals(boundingBox, boundingBox.getIntersection(boundingBox));
}
use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.
the class TestBoundingBox method testFromAndToByteArray.
/**
* Test from and to byte array
*/
@Test(timeout = 60000)
public void testFromAndToByteArray() {
final BoundingBox boundingBox1 = new BoundingBox(1d, 2d, 3d, 4d);
final byte[] bytes = boundingBox1.toByteArray();
final BoundingBox boundingBox2 = BoundingBox.fromByteArray(bytes);
Assert.assertEquals(boundingBox1, boundingBox2);
}
use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.
the class TestBoundingBox method testCompareTo.
/**
* Test the compare to method
*/
@Test(timeout = 60000)
public void testCompareTo() {
final BoundingBox boundingBox1 = new BoundingBox(1d, 2d, 3d, 4d);
final BoundingBox boundingBox2 = new BoundingBox(1d, 2d);
Assert.assertEquals(0, boundingBox1.compareTo(boundingBox1));
Assert.assertTrue(boundingBox1.compareTo(boundingBox2) > 0);
Assert.assertTrue(boundingBox2.compareTo(boundingBox1) < 0);
}
use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.
the class TestBoundingBox method testOverlapping2D.
/**
* Test the overlapping in 2d
*/
@Test(timeout = 60000)
public void testOverlapping2D() {
final BoundingBox bb1left = new BoundingBox(0d, 1d, 0d, 1d);
final BoundingBox bb1leftinside = new BoundingBox(0.5d, 0.7d, 0.5d, 0.7d);
Assert.assertTrue(bb1left.overlaps(bb1leftinside));
Assert.assertTrue(bb1leftinside.overlaps(bb1left));
final BoundingBox bb1middle = new BoundingBox(0.5d, 1.5d, 0.5d, 1.5d);
Assert.assertTrue(bb1left.overlaps(bb1middle));
Assert.assertTrue(bb1middle.overlaps(bb1left));
final BoundingBox bb1right = new BoundingBox(1d, 2d, 10d, 11d);
Assert.assertFalse(bb1left.overlaps(bb1right));
Assert.assertFalse(bb1right.overlaps(bb1left));
}
use of org.bboxdb.commons.math.BoundingBox in project bboxdb by jnidzwetzki.
the class DistributionRegionComponent method getToolTipText.
/**
* Get the tooltip text
* @return
*/
public String getToolTipText() {
final StringBuilder sb = new StringBuilder("<html>");
try {
final Map<BBoxDBInstance, Map<String, Long>> statistics = addStatisticsToTooltip(sb);
final BoundingBox boundingBox = distributionRegion.getConveringBox();
for (int i = 0; i < boundingBox.getDimension(); i++) {
final DoubleInterval floatInterval = boundingBox.getIntervalForDimension(i);
sb.append("Dimension: " + i + " ");
sb.append(floatInterval.toString());
sb.append("<br>");
}
final Collection<BBoxDBInstance> systems = distributionRegion.getSystems();
for (final BBoxDBInstance instance : systems) {
if (!statistics.keySet().contains(instance)) {
sb.append("System: ");
sb.append(instance.toGUIString(guiModel.isScreenshotMode()));
sb.append(" <br>");
}
}
final boolean mergeableByZookeeper = RegionMergeHelper.isMergingByZookeeperAllowed(distributionRegion);
final boolean mergeableBySpacePartitioner = RegionMergeHelper.isMergingBySpacePartitionerAllowed(distributionRegion);
sb.append("Merge supported by configuration <i>" + mergeableByZookeeper + "</i>, by space partitioner <i>" + mergeableBySpacePartitioner + "</i><br>");
final boolean isSplitSupported = RegionSplitHelper.isSplittingSupported(distributionRegion);
sb.append("Split supported by space partitioner <i>" + isSplitSupported + "</i><br>");
} catch (Exception e) {
logger.error("Got an exception while reading statistics for distribution group", e);
}
sb.append("</html>");
return sb.toString();
}
Aggregations