Search in sources :

Example 16 with DoubleInterval

use of org.bboxdb.commons.math.DoubleInterval in project bboxdb by jnidzwetzki.

the class TestDoubleInterval method testMidpoint1.

/**
 * Test midpoint calculation
 */
@Test(timeout = 60000)
public void testMidpoint1() {
    final DoubleInterval interval1 = new DoubleInterval(DoubleInterval.MIN_VALUE, DoubleInterval.MAX_VALUE);
    Assert.assertEquals(0, interval1.getMidpoint(), 0.0001f);
}
Also used : DoubleInterval(org.bboxdb.commons.math.DoubleInterval) Test(org.junit.Test)

Example 17 with DoubleInterval

use of org.bboxdb.commons.math.DoubleInterval in project bboxdb by jnidzwetzki.

the class TestDoubleInterval method testIntersection5.

/**
 * Test intersection calculation
 */
@Test(timeout = 60000)
public void testIntersection5() {
    final DoubleInterval floatInterval2 = new DoubleInterval(5, 10, true, true);
    final DoubleInterval floatInterval1 = new DoubleInterval(1, 11, true, true);
    Assert.assertTrue(floatInterval2.getIntersection(floatInterval1) != null);
    Assert.assertEquals(floatInterval2, floatInterval2.getIntersection(floatInterval1));
    Assert.assertTrue(floatInterval1.getIntersection(floatInterval2) != null);
    Assert.assertEquals(floatInterval2, floatInterval1.getIntersection(floatInterval2));
}
Also used : DoubleInterval(org.bboxdb.commons.math.DoubleInterval) Test(org.junit.Test)

Example 18 with DoubleInterval

use of org.bboxdb.commons.math.DoubleInterval 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();
}
Also used : BoundingBox(org.bboxdb.commons.math.BoundingBox) DoubleInterval(org.bboxdb.commons.math.DoubleInterval) BBoxDBInstance(org.bboxdb.distribution.membership.BBoxDBInstance) Map(java.util.Map) ZookeeperNotFoundException(org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException) ZookeeperException(org.bboxdb.distribution.zookeeper.ZookeeperException)

Example 19 with DoubleInterval

use of org.bboxdb.commons.math.DoubleInterval in project bboxdb by jnidzwetzki.

the class TestDoubleInterval method testIntersection3.

/**
 * Test intersection calculation
 */
@Test(timeout = 60000)
public void testIntersection3() {
    final DoubleInterval floatInterval1 = new DoubleInterval(1, 2, true, true);
    final DoubleInterval floatInterval2 = new DoubleInterval(2, 3, true, true);
    Assert.assertTrue(floatInterval1.getIntersection(floatInterval2) != null);
    Assert.assertTrue(floatInterval2.getIntersection(floatInterval1) != null);
    final DoubleInterval floatIntervalResult = new DoubleInterval(2, 2, true, true);
    Assert.assertEquals(floatIntervalResult, floatInterval1.getIntersection(floatInterval2));
    Assert.assertEquals(floatIntervalResult, floatInterval2.getIntersection(floatInterval1));
}
Also used : DoubleInterval(org.bboxdb.commons.math.DoubleInterval) Test(org.junit.Test)

Example 20 with DoubleInterval

use of org.bboxdb.commons.math.DoubleInterval in project bboxdb by jnidzwetzki.

the class TestDoubleInterval method testIntersection4.

/**
 * Test intersection calculation
 */
@Test(timeout = 60000)
public void testIntersection4() {
    final DoubleInterval floatInterval1 = new DoubleInterval(5, 10, true, true);
    final DoubleInterval floatInterval2 = new DoubleInterval(1, 11, true, true);
    Assert.assertTrue(floatInterval1.getIntersection(floatInterval2) != null);
    Assert.assertEquals(floatInterval1, floatInterval1.getIntersection(floatInterval2));
    Assert.assertTrue(floatInterval2.getIntersection(floatInterval1) != null);
    Assert.assertEquals(floatInterval1, floatInterval2.getIntersection(floatInterval1));
}
Also used : DoubleInterval(org.bboxdb.commons.math.DoubleInterval) Test(org.junit.Test)

Aggregations

DoubleInterval (org.bboxdb.commons.math.DoubleInterval)38 Test (org.junit.Test)29 BoundingBox (org.bboxdb.commons.math.BoundingBox)10 ArrayList (java.util.ArrayList)5 List (java.util.List)3 Color (java.awt.Color)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 BBoxDBInstance (org.bboxdb.distribution.membership.BBoxDBInstance)1 ZookeeperException (org.bboxdb.distribution.zookeeper.ZookeeperException)1 ZookeeperNotFoundException (org.bboxdb.distribution.zookeeper.ZookeeperNotFoundException)1 TupleListFuture (org.bboxdb.network.client.future.TupleListFuture)1