Java 类javafx.geometry.BoundingBox 实例源码

项目:HTWK_Visu    文件:MapCanvas.java   
@Override
public void redraw() {
    timer.reset();
    tmpWidth = getWidth();
    tmpHeight = getHeight();
    double coveredWidth = tmpWidth / scale;
    double coveredHeight = tmpHeight / scale;
    coordsBounds = new BoundingBox(mapCenter.getX() - coveredHeight / 2, mapCenter.getY() - coveredWidth / 2,
            coveredHeight, coveredWidth);
    heightDistance = MathUtils.convertUnitsToKilometres(coordsBounds.getWidth());
    widthDistance = MathUtils.convertUnitsToKilometres(coordsBounds.getHeight());

    // clear view
    gc.clearRect(0, 0, tmpWidth, tmpHeight);

    // draw map content
    if (!isInDragMode()) {
        drawScoringValues();
    }
    drawGrid();
    drawElements();
    drawInfo();
    timer.logInfo();
}
项目:openjfx-8u-dev-tests    文件:RelativeMouse.java   
static Boolean isInWindow(final NodeWrap<? extends Node> node, final Point p) {
    return new FutureAction<>(node.getEnvironment(), () -> {
        Window window = node.getControl().getScene().getWindow();
        if (Double.isNaN(window.getX())) { // TODO: temporary stub for RT-12736
            return true;
        }
        Bounds bounds = new BoundingBox(window.getX(), window.getY(), 0, window.getWidth(), window.getHeight(), 0);
        double x = node.getScreenBounds().getX();
        double y = node.getScreenBounds().getY();
        if (p == null) {
            x += node.getClickPoint().getX();
            y += node.getClickPoint().getY();
        } else {
            x += p.getX();
            y += p.getY();
        }
        return (bounds.contains(x, y));
    }).get();
}
项目:j.commons    文件:CompositeObservableBoundsTest.java   
@Test
public void createCompositeObservableBoundsWithValidBounds() {
    final Bounds b1 = new BoundingBox(10, 20, 30, 100, 200, 300);
    final ObjectProperty<Bounds> boundsProperty = new SimpleObjectProperty<>(b1);

    final CompositeObservableBounds cut = new CompositeObservableBounds(boundsProperty);

    assertEquals("minX value", 10, cut.minXProperty().get(), Precision.EPSILON);
    assertEquals("minY value", 20, cut.minYProperty().get(), Precision.EPSILON);
    assertEquals("minZ value", 30, cut.minZProperty().get(), Precision.EPSILON);
    assertEquals("centerX value", 60, cut.centerXProperty().get(), Precision.EPSILON);
    assertEquals("centerY value", 120, cut.centerYProperty().get(), Precision.EPSILON);
    assertEquals("centerZ value", 180, cut.centerZProperty().get(), Precision.EPSILON);
    assertEquals("maxX value", 110, cut.maxXProperty().get(), Precision.EPSILON);
    assertEquals("maxY value", 220, cut.maxYProperty().get(), Precision.EPSILON);
    assertEquals("maxZ value", 330, cut.maxZProperty().get(), Precision.EPSILON);

}
项目:viskell    文件:Block.java   
/** Scans for and attaches to a new container, if any */
public void refreshContainer() {
    Bounds myBounds = this.getBodyBounds();
    Point2D center = new Point2D((myBounds.getMinX()+myBounds.getMaxX())/2, (myBounds.getMinY()+myBounds.getMaxY())/2);
    List<Point2D> corners = ImmutableList.of(
            new Point2D(myBounds.getMinX(), myBounds.getMinY()),
            new Point2D(myBounds.getMaxX(), myBounds.getMinY()),
            new Point2D(myBounds.getMinX(), myBounds.getMaxY()),
            new Point2D(myBounds.getMaxX(), myBounds.getMaxY()));

    // use center point plus one corner to determine wherein this block is, to ease moving a block into a small container
    Predicate<Bounds> within = bounds -> bounds.contains(center) && corners.stream().anyMatch(bounds::contains);

    // a container may never end up in itself or its children
    List<? extends WrappedContainer> internals = this.getInternalContainers();
    Predicate<BlockContainer> notInSelf = con -> internals.stream().noneMatch(con::isContainedWithin);

    BlockContainer newContainer = toplevel.getAllBlockContainers().
        filter(container -> within.test(container.containmentBoundsInScene()) && notInSelf.test(container)).
            reduce((a, b) -> !a.containmentBoundsInScene().contains(b.containmentBoundsInScene()) ? a : b).
                orElse(this.toplevel);

    Bounds fitBounds = this.localToParent(this.sceneToLocal(myBounds));
    this.moveIntoContainer(newContainer);
    newContainer.expandToFit(new BoundingBox(fitBounds.getMinX()-10, fitBounds.getMinY()-10, fitBounds.getWidth()+20, fitBounds.getHeight()+20));
}
项目:viskell    文件:Lane.java   
/** Add and initializes a resizer element to this block */
private void setupResizer() {
    Polygon triangle = new Polygon();
    triangle.getPoints().addAll(new Double[]{20.0, 20.0, 20.0, 0.0, 0.0, 20.0});
    triangle.setFill(Color.BLUE);

    this.resizer = new Pane(triangle);
    triangle.setLayoutX(10);
    triangle.setLayoutY(10);
    this.resizer.setManaged(false);
    this.getChildren().add(this.resizer);
    this.resizer.relocate(240-20, 320-20);

    DragContext sizeDrag = new DragContext(this.resizer);
    sizeDrag.setDragLimits(new BoundingBox(200, 200, Integer.MAX_VALUE, Integer.MAX_VALUE));
}
项目:JFoenix    文件:JFXMasonryPane.java   
protected boolean validWidth(BoundingBox box, Region region, double cellW, double gutterX, double gutterY) {
    boolean valid = false;
    if (region.getMinWidth() != -1 && box.getWidth() * cellW + (box.getWidth() - 1) * 2 * gutterX < region.getMinWidth()) {
        return false;
    }

    if (region.getPrefWidth() == USE_COMPUTED_SIZE && box.getWidth() * cellW + (box.getWidth() - 1) * 2 * gutterX >= region
        .prefWidth(-1)) {
        valid = true;
    }
    if (region.getPrefWidth() != USE_COMPUTED_SIZE && box.getWidth() * cellW + (box.getWidth() - 1) * 2 * gutterX >= region
        .getPrefWidth()) {
        valid = true;
    }
    return valid;
}
项目:JFoenix    文件:JFXMasonryPane.java   
protected boolean validHeight(BoundingBox box, Region region, double cellH, double gutterX, double gutterY) {
    boolean valid = false;
    if (region.getMinHeight() != -1 && box.getHeight() * cellH + (box.getHeight() - 1) * 2 * gutterY < region.getMinHeight()) {
        return false;
    }

    if (region.getPrefHeight() == USE_COMPUTED_SIZE && box.getHeight() * cellH + (box.getHeight() - 1) * 2 * gutterY >= region
        .prefHeight(region.prefWidth(-1))) {
        valid = true;
    }
    if (region.getPrefHeight() != USE_COMPUTED_SIZE && box.getHeight() * cellH + (box.getHeight() - 1) * 2 * gutterY >= region
        .getPrefHeight()) {
        valid = true;
    }
    return valid;
}
项目:ShootOFF    文件:CanvasManager.java   
public Bounds translateCameraToCanvas(Bounds bounds) {
    if (config.getDisplayWidth() == cameraManager.getFeedWidth()
            && config.getDisplayHeight() == cameraManager.getFeedHeight())
        return bounds;

    final double scaleX = (double) config.getDisplayWidth() / (double) cameraManager.getFeedWidth();
    final double scaleY = (double) config.getDisplayHeight() / (double) cameraManager.getFeedHeight();

    final double minX = (bounds.getMinX() * scaleX);
    final double minY = (bounds.getMinY() * scaleY);
    final double width = (bounds.getWidth() * scaleX);
    final double height = (bounds.getHeight() * scaleY);

    logger.trace("translateCameraToCanvas {} {} {} {} - {} {} {} {}", bounds.getMinX(), bounds.getMinY(),
            bounds.getWidth(), bounds.getHeight(), minX, minY, width, height);

    return new BoundingBox(minX, minY, width, height);
}
项目:ShootOFF    文件:CanvasManager.java   
public Bounds translateCanvasToCamera(Bounds bounds) {
    if (config.getDisplayWidth() == cameraManager.getFeedWidth()
            && config.getDisplayHeight() == cameraManager.getFeedHeight())
        return bounds;

    final double scaleX = (double) cameraManager.getFeedWidth() / (double) config.getDisplayWidth();
    final double scaleY = (double) cameraManager.getFeedHeight() / (double) config.getDisplayHeight();

    final double minX = (bounds.getMinX() * scaleX);
    final double minY = (bounds.getMinY() * scaleY);
    final double width = (bounds.getWidth() * scaleX);
    final double height = (bounds.getHeight() * scaleY);

    logger.trace("translateCanvasToCamera {} {} {} {} - {} {} {} {}", bounds.getMinX(), bounds.getMinY(),
            bounds.getWidth(), bounds.getHeight(), minX, minY, width, height);

    return new BoundingBox(minX, minY, width, height);
}
项目:ShootOFF    文件:TestCameraManagerDark.java   
@Test
// DARK
public void testPS3EyeHardwareDefaultsBrightRoomLimitedBounds() {
    // Turn off the top sectors because they are all just noise.
    for (int x = 0; x < JavaShotDetector.SECTOR_ROWS; x++) {
        sectorStatuses[0][x] = false;
    }

    Bounds projectionBounds = new BoundingBox(109, 104, 379, 297);

    List<DisplayShot> shots = findShots("/shotsearcher/ps3eye_hardware_defaults_bright_room.mp4",
            Optional.of(projectionBounds), mockManager, config, sectorStatuses);

    List<Shot> requiredShots = new ArrayList<Shot>();
    requiredShots.add(new Shot(ShotColor.RED, 176.5, 251.3, 0, 2));

    List<Shot> optionalShots = new ArrayList<Shot>();
    optionalShots.add(new Shot(ShotColor.RED, 236.5, 169.5, 0, 2));
    optionalShots.add(new Shot(ShotColor.RED, 175, 191.5, 0, 2));
    optionalShots.add(new Shot(ShotColor.RED, 229.5, 227.5, 0, 2));

    super.checkShots(collector, shots, requiredShots, optionalShots, false);
}
项目:ShootOFF    文件:TestCameraManagerDark.java   
@Test
// DARK
public void testPS3EyeHardwareDefaultsRedLaserRoomLightOnSafariLimitedBounds() {
    Bounds projectionBounds = new BoundingBox(131, 77, 390, 265);

    List<DisplayShot> shots = findShots("/shotsearcher/ps3eye_hardware_defaults_safari_red_laser_lights_on.mp4",
            Optional.of(projectionBounds), mockManager, config, sectorStatuses);

    List<Shot> requiredShots = new ArrayList<Shot>();
    requiredShots.add(new Shot(ShotColor.RED, 473.6, 126.5, 0, 2));
    requiredShots.add(new Shot(ShotColor.RED, 349.2, 130.5, 0, 2));
    requiredShots.add(new Shot(ShotColor.RED, 207.3, 113.5, 0, 2));
    requiredShots.add(new Shot(ShotColor.RED, 183.1, 226.9, 0, 2));
    requiredShots.add(new Shot(ShotColor.RED, 310.5, 228.5, 0, 2));
    requiredShots.add(new Shot(ShotColor.RED, 468.7, 219.8, 0, 2));
    requiredShots.add(new Shot(ShotColor.RED, 469.8, 268.5, 0, 2));
    requiredShots.add(new Shot(ShotColor.RED, 339.9, 291.8, 0, 2));
    requiredShots.add(new Shot(ShotColor.RED, 201.5, 297.7, 0, 2));

    super.checkShots(collector, shots, requiredShots, new ArrayList<Shot>(), true);
}
项目:ShootOFF    文件:TestPerspectiveManager.java   
@Test
public void testTwo() throws ConfigurationException {
    PerspectiveManager pm = new PerspectiveManager(new BoundingBox(0, 0, 422, 316));

    pm.setCameraParameters(4, 3.125, 2.32);
    pm.setCameraFeedSize(640, 480);
    pm.setCameraDistance(3406);
    pm.setShooterDistance(3406);
    pm.setProjectorResolution(1024, 768);

    pm.calculateUnknown();

    assertEquals(1753.0, pm.getProjectionWidth(), 1);
    assertEquals(1299.0, pm.getProjectionHeight(), 1);

    Optional<Dimension2D> dims = pm.calculateObjectSize(300, 200, 3406);

    assertTrue(dims.isPresent());
    assertEquals(175.3, dims.get().getWidth(), 1);
    assertEquals(118.2, dims.get().getHeight(), 1);
}
项目:ShootOFF    文件:TestPerspectiveManager.java   
@Test
public void testThree() throws ConfigurationException {
    PerspectiveManager pm = new PerspectiveManager(new BoundingBox(0, 0, 422, 316));

    pm.setProjectionSize(1753, 1299);
    pm.setCameraFeedSize(640, 480);
    pm.setCameraDistance(3406);
    pm.setShooterDistance(3406);
    pm.setProjectorResolution(1024, 768);

    pm.calculateUnknown();

    assertEquals(4, pm.getFocalLength(), 1);
    assertEquals(3.122, pm.getSensorWidth(), .01);
    assertEquals(2.317, pm.getSensorHeight(), .01);

    Optional<Dimension2D> dims = pm.calculateObjectSize(300, 200, 3406);

    assertTrue(dims.isPresent());
    assertEquals(175.3, dims.get().getWidth(), 1);
    assertEquals(118.2, dims.get().getHeight(), 1);
}
项目:ShootOFF    文件:TestPerspectiveManager.java   
@Test
public void testPaperPixelsCalcParams() throws ConfigurationException {
    PerspectiveManager pm = new PerspectiveManager(new BoundingBox(0, 0, 422, 316), new Dimension2D(640, 480),
            new Dimension2D(67, 53), new Dimension2D(1024, 768));

    pm.setCameraDistance(3498);

    pm.setShooterDistance(3498);

    pm.calculateUnknown();

    assertEquals(4, pm.getFocalLength(), 1);
    assertEquals(3.047, pm.getSensorWidth(), .01);
    assertEquals(2.235, pm.getSensorHeight(), .01);

    Optional<Dimension2D> dims = pm.calculateObjectSize(279, 216, pm.getCameraDistance());

    assertTrue(dims.isPresent());
    assertEquals(162.6, dims.get().getWidth(), 1);
    assertEquals(128.9, dims.get().getHeight(), 1);
}
项目:JVx.javafx    文件:FXInternalWindow.java   
/**
 * Invoked if the state property changes.
 * 
 * @param pObservable the observable.
 * @param pOldValue the old value.
 * @param pNewValue the new value.
 */
private void onStateChanged(ObservableValue<? extends State> pObservable, State pOldValue, State pNewValue)
{
    if (pOldValue != pNewValue)
    {
        // We need to construct the bounds ourselves, because
        // the given bounds are not always up to date.
        Bounds bounds = new BoundingBox(getLayoutX(), getLayoutY(), getWidth(), getHeight());

        previousBounds.put(pOldValue, bounds);
        previousState = pOldValue;

        pseudoClassStateChanged(MAXIMIZED_PSEUDO_CLASS, pNewValue == State.MAXIMIZED);
        pseudoClassStateChanged(MINIMIZED_PSEUDO_CLASS, pNewValue == State.MINIMIZED);

        zoomReset();

        fireEvent(new WindowStateChangedEvent(this, pOldValue, pNewValue), onStateChanged);
    }
}
项目:JVx.javafx    文件:FXBorderPane.java   
/**
 * {@inheritDoc}
 */
@Override
protected void layoutChildren()
{
    Insets padding = getPadding();
    if (padding == null)
    {
        padding = Insets.EMPTY;
    }

    Bounds baseBounds = new BoundingBox(
            snapPosition(padding.getLeft()),
            snapPosition(padding.getTop()),
            snapPosition(getWidth() - padding.getLeft() - padding.getRight()),
            snapPosition(getHeight() - padding.getTop() - padding.getBottom()));

    double fromTop = layoutTop(baseBounds);
    double fromBottom = layoutBottom(baseBounds);
    double fromLeft = layoutLeft(baseBounds, fromTop, fromBottom);
    double fromRight = layoutRight(baseBounds, fromTop, fromBottom);

    layoutCenter(baseBounds, fromTop, fromBottom, fromLeft, fromRight);
}
项目:contentment    文件:PointPairTest.java   
@Test
public void constructors()
{
    PointPair[] pairs = new PointPair[]
    {
            new PointPair(50d, 150d, 200d, 400d),
            new PointPair(new Point(50d, 150d), new Point(200d, 400d)),
            new PointPair(new BoundingBox(50d, 150d, 150d, 250d)),
            new PointPair(new Rectangle(50d, 150d, 150d, 250d))
    };
    for (PointPair pair : pairs)
    {
        assertEquals(50d, pair.from.x, 0.0001);
        assertEquals(150d, pair.from.y, 0.0001);
        assertEquals(200d, pair.to.x, 0.0001);
        assertEquals(400d, pair.to.y, 0.0001);
    }
}
项目:RichTextFX    文件:GenericStyledArea.java   
final Optional<Bounds> getSelectionBoundsOnScreen(Selection selection) {
    if (selection.getLength() == 0) {
        return Optional.empty();
    }

    List<Bounds> bounds = new ArrayList<>(selection.getParagraphSpan());
    for (int i = selection.getStartParagraphIndex(); i <= selection.getEndParagraphIndex(); i++) {
        final int i0 = i;
        virtualFlow.getCellIfVisible(i).ifPresent(c -> {
            IndexRange rangeWithinPar = getParagraphSelection(selection, i0);
            Bounds b = c.getNode().getRangeBoundsOnScreen(rangeWithinPar);
            bounds.add(b);
        });
    }

    if(bounds.size() == 0) {
        return Optional.empty();
    }
    double minX = bounds.stream().mapToDouble(Bounds::getMinX).min().getAsDouble();
    double maxX = bounds.stream().mapToDouble(Bounds::getMaxX).max().getAsDouble();
    double minY = bounds.stream().mapToDouble(Bounds::getMinY).min().getAsDouble();
    double maxY = bounds.stream().mapToDouble(Bounds::getMaxY).max().getAsDouble();
    return Optional.of(new BoundingBox(minX, minY, maxX-minX, maxY-minY));
}
项目:RichTextFX    文件:GenericStyledArea.java   
private Bounds getParagraphBoundsOnScreen(Cell<Paragraph<PS, SEG, S>, ParagraphBox<PS, SEG, S>> cell) {
    Bounds nodeLocal = cell.getNode().getBoundsInLocal();
    Bounds nodeScreen = cell.getNode().localToScreen(nodeLocal);
    Bounds areaLocal = getBoundsInLocal();
    Bounds areaScreen = localToScreen(areaLocal);

    // use area's minX if scrolled right and paragraph's left is not visible
    double minX = nodeScreen.getMinX() < areaScreen.getMinX()
            ? areaScreen.getMinX()
            : nodeScreen.getMinX();
    // use area's minY if scrolled down vertically and paragraph's top is not visible
    double minY = nodeScreen.getMinY() < areaScreen.getMinY()
            ? areaScreen.getMinY()
            : nodeScreen.getMinY();
    // use area's width whether paragraph spans outside of it or not
    // so that short or long paragraph takes up the entire space
    double width = areaScreen.getWidth();
    // use area's maxY if scrolled up vertically and paragraph's bottom is not visible
    double maxY = nodeScreen.getMaxY() < areaScreen.getMaxY()
            ? nodeScreen.getMaxY()
            : areaScreen.getMaxY();
    return new BoundingBox(minX, minY, width, maxY - minY);
}
项目:GestureFX    文件:GesturePaneTest.java   
@Test
public void testContainerBoundChanged() throws Exception {
    pane.setScrollBarEnabled(false);
    pane.getScene().getWindow().setWidth(256);
    pane.getScene().getWindow().setHeight(256);
    Thread.sleep(150); // wait for layout
    assertThat(pane.getViewportBound()).isEqualTo(new BoundingBox(0, 0, 256, 256));
    assertThat(pane.viewportCentre()).isEqualTo(new Point2D(128, 128));
}
项目:fx-animation-editor    文件:MathFunctions.java   
public static Bounds union(Bounds first, Bounds second) {
    if (first == null) {
        return second;
    } else if (second == null) {
        return first;
    }
    double minX = Math.min(first.getMinX(), second.getMinX());
    double minY = Math.min(first.getMinY(), second.getMinY());
    double maxX = Math.max(first.getMaxX(), second.getMaxX());
    double maxY = Math.max(first.getMaxY(), second.getMaxY());
    return new BoundingBox(minX, minY, maxX - minX, maxY - minY);
}
项目:FxDock    文件:DropOp.java   
public void addRect(Node ref, double x, double y, double w, double h)
{
    BoundingBox screenr = new BoundingBox(x, y, w, h);
    Bounds b = ref.localToScreen(screenr);
    b = target.screenToLocal(b);

    Region r = new Region();
    r.relocate(b.getMinX(), b.getMinY());
    r.resize(b.getWidth(), b.getHeight());
    r.setBackground(FX.background(Color.color(0, 0, 0, 0.3)));

    add(r);
}
项目:FxDock    文件:DropOp.java   
public void addOutline(Node ref, double x, double y, double w, double h)
{
    BoundingBox screenr = new BoundingBox(x, y, w, h);
    Bounds b = ref.localToScreen(screenr);
    b = target.screenToLocal(b);

    Region r = new Region();
    r.relocate(b.getMinX(), b.getMinY());
    r.resize(b.getWidth(), b.getHeight());
    r.setBackground(FX.background(Color.color(0, 0, 0, 0.1)));

    add(r);
}
项目:j.commons    文件:CompositeObservableBoundsTest.java   
@Test(expected = NullPointerException.class)
public void callAddWithNullBounds() {
    final Bounds b1 = new BoundingBox(10, 20, 30, 100, 200, 300);
    final ObjectProperty<Bounds> boundsProperty = new SimpleObjectProperty<>(b1);

    final CompositeObservableBounds cut = new CompositeObservableBounds(boundsProperty);

    cut.add(null);
}
项目:j.commons    文件:CompositeObservableBoundsTest.java   
@Test
public void callClear() {
    final Bounds b1 = new BoundingBox(10, 20, 30, 100, 200, 300);
    final ObjectProperty<Bounds> boundsProperty = new SimpleObjectProperty<>(b1);

    final CompositeObservableBounds cut = new CompositeObservableBounds(boundsProperty);

    assertEquals("minX value", 10, cut.minXProperty().get(), Precision.EPSILON);
    assertEquals("minY value", 20, cut.minYProperty().get(), Precision.EPSILON);
    assertEquals("minZ value", 30, cut.minZProperty().get(), Precision.EPSILON);
    assertEquals("centerX value", 60, cut.centerXProperty().get(), Precision.EPSILON);
    assertEquals("centerY value", 120, cut.centerYProperty().get(), Precision.EPSILON);
    assertEquals("centerZ value", 180, cut.centerZProperty().get(), Precision.EPSILON);
    assertEquals("maxX value", 110, cut.maxXProperty().get(), Precision.EPSILON);
    assertEquals("maxY value", 220, cut.maxYProperty().get(), Precision.EPSILON);
    assertEquals("maxZ value", 330, cut.maxZProperty().get(), Precision.EPSILON);

    cut.clear();

    assertEquals("minX value", 0, cut.minXProperty().get(), Precision.EPSILON);
    assertEquals("minY value", 0, cut.minYProperty().get(), Precision.EPSILON);
    assertEquals("minZ value", 0, cut.minZProperty().get(), Precision.EPSILON);
    assertEquals("centerX value", 0, cut.centerXProperty().get(), Precision.EPSILON);
    assertEquals("centerY value", 0, cut.centerYProperty().get(), Precision.EPSILON);
    assertEquals("centerZ value", 0, cut.centerZProperty().get(), Precision.EPSILON);
    assertEquals("maxX value", 0, cut.maxXProperty().get(), Precision.EPSILON);
    assertEquals("maxY value", 0, cut.maxYProperty().get(), Precision.EPSILON);
    assertEquals("maxZ value", 0, cut.maxZProperty().get(), Precision.EPSILON);
}
项目:FXGL    文件:HitBox.java   
private void readObject(java.io.ObjectInputStream in) throws IOException, ClassNotFoundException {
    name = (String) in.readObject();

    bounds = new BoundingBox(in.readDouble(), in.readDouble(), in.readDouble(), in.readDouble());

    Dimension2D size = new Dimension2D(in.readDouble(), in.readDouble());

    ShapeType type = (ShapeType) in.readObject();

    switch (type) {

        case CIRCLE:
            shape = BoundingShape.circle(size.getWidth() / 2);
            break;

        case POLYGON:
            shape = BoundingShape.box(size.getWidth(), size.getHeight());
            break;

        case CHAIN:
            int length = in.readInt();

            Point2D[] points = new Point2D[length];
            for (int i = 0; i < length; i++) {
                points[i] = new Point2D(in.readDouble(), in.readDouble());
            }
            shape = BoundingShape.chain(points);
            break;

        default:
            throw new IllegalArgumentException("Unknown shape type");
    }
}
项目:viskell    文件:BlockContainer.java   
/** Return the union of two Bounds, i.e. a Bound that contains both. */
static Bounds union(Bounds a, Bounds b) {
    double left   = Math.min(a.getMinX(), b.getMinX());
    double right  = Math.max(a.getMaxX(), b.getMaxX());
    double top    = Math.min(a.getMinY(), b.getMinY());
    double bottom = Math.max(a.getMaxY(), b.getMaxY());

    return new BoundingBox(left, top, right - left, bottom - top);
}
项目:viskell    文件:ToplevelPane.java   
/**
 * @param pos the position to look around in coordinate system of this pane. 
 * @param distance the maximum 'nearby' distance.
 */
public List<ConnectionAnchor> allNearbyFreeAnchors(Point2D pos, double distance) {
    ArrayList<ConnectionAnchor> anchors = new ArrayList<>(); 
    Bounds testBounds = new BoundingBox(pos.getX()-distance, pos.getY()-distance, distance*2, distance*2);
    for (Block nearBlock : this.streamChildren().filter(n -> n instanceof Block).map(n -> (Block)n).filter(b -> b.getBoundsInParent().intersects(testBounds)).collect(Collectors.toList())) {
        for (ConnectionAnchor anchor : nearBlock.getAllAnchors()) {
            Point2D anchorPos = anchor.getAttachmentPoint();
            if (pos.distance(anchorPos) < distance  && anchor.getWireInProgress() == null && !anchor.hasConnection()) {
                anchors.add(anchor);
            }
        }
    }

    return anchors;
}
项目:viskell    文件:Lane.java   
@Override
public Bounds containmentBoundsInScene() {
    Bounds local = this.getBoundsInLocal();
    // include border area around this lane
    BoundingBox withBorders = new BoundingBox(local.getMinX()-10, local.getMinY()-25, local.getWidth()+20, local.getHeight()+50);
    return this.localToScene(withBorders);
}
项目:viskell    文件:Lane.java   
@Override
public void expandToFit(Bounds blockBounds) {
    Bounds containerBounds = this.parent.getToplevel().sceneToLocal(this.getCenter().localToScene(this.getCenter().getBoundsInLocal()));
    double shiftX = Math.min(0, blockBounds.getMinX() - containerBounds.getMinX());
    double shiftY = Math.min(0, blockBounds.getMinY() - containerBounds.getMinY());
    double extraX = Math.max(0, blockBounds.getMaxX() - containerBounds.getMaxX()) + Math.abs(shiftX);
    double extraY = Math.max(0, blockBounds.getMaxY() - containerBounds.getMaxY()) + Math.abs(shiftY);
    this.resizer.relocate(this.resizer.getLayoutX() + extraX, this.resizer.getLayoutY() + extraY);
    double shiftXForRights = extraX + shiftX;
    this.parent.shiftAllBut(shiftX, shiftY, this, shiftXForRights);

    // also resize its parent in case of nested containers
    Bounds fitBounds = this.parent.getBoundsInParent();
    this.getParentContainer().expandToFit(new BoundingBox(fitBounds.getMinX()-10, fitBounds.getMinY()-10, fitBounds.getWidth()+20, fitBounds.getHeight()+20));
}
项目:viskell    文件:LambdaContainer.java   
@Override
public Bounds containmentBoundsInScene() {
    Bounds local = this.getBoundsInLocal();
    // include top and bottom border of the DefinitionBlock
    BoundingBox withBorders = new BoundingBox(local.getMinX(), local.getMinY()-25, local.getWidth(), local.getHeight()+50);
    return this.localToScene(withBorders);
}
项目:viskell    文件:LambdaContainer.java   
@Override
public void expandToFit(Bounds blockBounds) {
    Bounds containerBounds = this.wrapper.getToplevel().sceneToLocal(this.getCenter().localToScene(this.getCenter().getBoundsInLocal()));
    double shiftX = Math.min(0, blockBounds.getMinX() - containerBounds.getMinX());
    double shiftY = Math.min(0, blockBounds.getMinY() - containerBounds.getMinY());
    double extraX = Math.max(0, blockBounds.getMaxX() - containerBounds.getMaxX()) + Math.abs(shiftX);
    double extraY = Math.max(0, blockBounds.getMaxY() - containerBounds.getMaxY()) + Math.abs(shiftY);
    this.wrapper.shiftAndGrow(shiftX, shiftY, extraX, extraY);

    // also resize its parent in case of nested containers
    Bounds fitBounds = this.wrapper.getBoundsInParent();
    this.getParentContainer().expandToFit(new BoundingBox(fitBounds.getMinX()-10, fitBounds.getMinY()-10, fitBounds.getWidth()+20, fitBounds.getHeight()+20));
}
项目:javafx.DndTabPane    文件:DndTabPaneFactory.java   
private static MarkerFeedback handleOutline(Pane layoutNode, FeedbackData data) {
    TabOutlineMarker marker = null;

    for (Node n : layoutNode.getChildren()) {
        if (n instanceof TabOutlineMarker) {
            marker = (TabOutlineMarker) n;
        }
    }

    if (marker == null) {
        marker = new TabOutlineMarker(layoutNode.getBoundsInLocal(), new BoundingBox(data.bounds.getMinX(), data.bounds.getMinY(), data.bounds.getWidth(), data.bounds.getHeight()), data.dropType == DropType.BEFORE);
        marker.setManaged(false);
        marker.setMouseTransparent(true);
        layoutNode.getChildren().add(marker);
    } else {
        marker.updateBounds(layoutNode.getBoundsInLocal(), new BoundingBox(data.bounds.getMinX(), data.bounds.getMinY(), data.bounds.getWidth(), data.bounds.getHeight()), data.dropType == DropType.BEFORE);
        marker.setVisible(true);
    }

    final TabOutlineMarker fmarker = marker;

    return new MarkerFeedback(data) {

        @Override
        public void hide() {
            fmarker.setVisible(false);
        }
    };
}
项目:htm.java-examples    文件:BreakingNewsDemo.java   
public void configureView() {
    view = new BreakingNewsDemoView();
    view.autoModeProperty().addListener((v, o, n) -> { this.mode = n; });
    this.mode = view.autoModeProperty().get();
    view.startActionProperty().addListener((v, o, n) -> {
        if(n) {
            if(mode == Mode.AUTO) cursor++;
            start();
        }else{
            stop();
        }
    });
    view.runOneProperty().addListener((v, o, n) -> {
        this.cursor += n.intValue();
        runOne(jsonList.get(cursor), cursor);
    });
    view.flipStateProperty().addListener((v, o, n) -> {
        view.flipPaneProperty().get().flip();
    });

    view.setPrefSize(1370, 1160);
    view.setMinSize(1370, 1160);

    mainViewScroll  = new ScrollPane();
    mainViewScroll.setViewportBounds(new BoundingBox(0, 0, 1370, 1160));

    mainViewScroll.setHbarPolicy(ScrollBarPolicy.NEVER);
    mainViewScroll.setVbarPolicy(ScrollBarPolicy.AS_NEEDED);
    mainViewScroll.setContent(view);
    mainViewScroll.viewportBoundsProperty().addListener((v, o, n) -> {
        view.setPrefSize(Math.max(1370, n.getMaxX()), Math.max(1160, n.getMaxY()));//1370, 1160);
    });

    createDataStream();
    createAlgorithm();
}
项目:JFoenix    文件:JFXMasonryPane.java   
/**
 * returns the available box at the cell (x,y) of the grid that fits the block if existed
 *
 * @param x
 * @param y
 * @param block
 * @return
 */
protected BoundingBox getFreeArea(int[][] matrix, int x, int y, Region block, double cellWidth, double cellHeight, int limitRow, int limitCol, double gutterX, double gutterY) {
    double blockHeight = getBLockHeight(block);
    double blockWidth = getBLockWidth(block);

    int rowsNeeded = (int) Math.ceil(blockHeight / (cellHeight + gutterY));
    if (cellHeight * rowsNeeded + (rowsNeeded - 1) * 2 * gutterY < blockHeight) {
        rowsNeeded++;
    }
    int maxRow = Math.min(x + rowsNeeded, limitRow);

    int colsNeeded = (int) Math.ceil(blockWidth / (cellWidth + gutterX));
    if (cellWidth * colsNeeded + (colsNeeded - 1) * 2 * gutterX < blockWidth) {
        colsNeeded++;
    }
    int maxCol = Math.min(y + colsNeeded, limitCol);

    int minRow = maxRow;
    int minCol = maxCol;
    for (int i = x; i < minRow; i++) {
        for (int j = y; j < maxCol; j++) {
            if (matrix[i][j] != 0) {
                if (y < j && j < minCol) {
                    minCol = j;
                }
            }
        }
    }
    for (int i = x; i < maxRow; i++) {
        for (int j = y; j < minCol; j++) {
            if (matrix[i][j] != 0) {
                if (x < i && i < minRow) {
                    minRow = i;
                }
            }
        }
    }
    return new BoundingBox(x, y, minCol - y, minRow - x);
}
项目:ShootOFF    文件:TestPerspectiveManager.java   
@Test
public void testOne() throws ConfigurationException {
    assertTrue(PerspectiveManager.isCameraSupported("C270", new Dimension2D(1280, 720)));

    PerspectiveManager pm = new PerspectiveManager("C270", new Dimension2D(1280, 720), new BoundingBox(0, 0, 736, 544));

    pm.setCameraFeedSize(1280, 720);
    pm.setCameraDistance(3406);
    pm.setShooterDistance(3406);
    pm.setProjectorResolution(1024, 768);

    pm.calculateUnknown();

    assertEquals(1753.0, pm.getProjectionWidth(), 1);
    assertEquals(1299.0, pm.getProjectionHeight(), 1);

    Optional<Dimension2D> dims = pm.calculateObjectSize(300, 200, 3406);
    assertTrue(dims.isPresent());
    assertEquals(175.3, dims.get().getWidth(), 1);
    assertEquals(118.2, dims.get().getHeight(), 1);

    dims = pm.calculateObjectSize(300, 200, 3406*2);
    assertTrue(dims.isPresent());
    assertEquals(87.7, dims.get().getWidth(), 1);
    assertEquals(59.1, dims.get().getHeight(), 1);

    dims = pm.calculateObjectSize(300, 200, 3406 / 2);
    assertTrue(dims.isPresent());
    assertEquals(350.7, dims.get().getWidth(), 1);
    assertEquals(236.5, dims.get().getHeight(), 1);

    pm.setShooterDistance(3406 * 2);
    dims = pm.calculateObjectSize(300, 200, 3406);
    assertTrue(dims.isPresent());
    assertEquals(350.7, dims.get().getWidth(), 1);
    assertEquals(236.5, dims.get().getHeight(), 1);

}
项目:ShootOFF    文件:TestPerspectiveManager.java   
@Test(expected = IllegalArgumentException.class)
public void testDesiredDistanceCannotBeZero() {
    PerspectiveManager pm = new PerspectiveManager("C270", new Dimension2D(1280, 720), new BoundingBox(0, 0, 736, 544));

    pm.setCameraFeedSize(1280, 720);
    pm.setCameraDistance(3406);
    pm.setShooterDistance(3406);
    pm.setProjectorResolution(1024, 768);

    pm.calculateUnknown();

    pm.calculateObjectSize(10, 10, 0);
}
项目:ShootOFF    文件:TestTargetCommands.java   
@Before
public void setUp() throws ConfigurationException {
    System.setProperty("shootoff.home", System.getProperty("user.dir"));

    TextToSpeech.silence(true);
    TrainingExerciseBase.silence(true);

    config = new Configuration(new String[0]);
    canvasManager = new MockCanvasManager(config);
    cameraManager = new MockCameraManager();

    bounds = new BoundingBox(100, 100, 540, 260);

    cameraManager.setProjectionBounds(bounds);
    canvasManager.setCameraManager(cameraManager);

    ProjectorArenaPane projectorArenaPane = new MockProjectorArenaController(config, canvasManager);

    canvasManager.setProjectorArena(projectorArenaPane, bounds);
    canvasManager.getCanvasGroup().getChildren().clear();

    targets = new ArrayList<Target>();
    TargetComponents poiComponents = TargetIO.loadTarget(new File("targets/POI_Offset_Adjustment.target")).get();
    poiTarget = (TargetView) canvasManager.addTarget(
            new TargetView(poiComponents.getTargetGroup(), poiComponents.getTargetTags(), targets));
    targets.add(poiTarget);

    canvasManager.addTarget(new File("targets/POI_Offset_Adjustment.target"));

    canvasManager.getTargets().get(0).setDimensions(640, 360);
    canvasManager.getTargets().get(0).setPosition(0, 0);
}
项目:fr.xs.jtk    文件:BoundedReferential2D.java   
public BoundedReferential2D(BoundaryBox _objFX, BoundaryBox _objMAX, double _maxScale) {
    sceneFX      = new BoundingBox(0, 0, _objFX.getWidth(), _objFX.getHeight());
    max2D        = new BoundingBox(_objMAX.getMinX(), _objMAX.getMinY(), _objMAX.getWidth(), _objMAX.getHeight());
    scene2D      = new BoundingBox(_objMAX.getMinX(), _objMAX.getMinY(), _objMAX.getWidth(), _objMAX.getHeight());
    maxScale     = new SimpleDoubleProperty(_maxScale);
    curScale     = new SimpleDoubleProperty(1.0);
    maxScale.addListener((_obs, _old, _new) -> setScaleMax(maxScale.getValue()) );
    curScale.addListener((_obs, _old, _new) -> setScale(curScale.getValue()) ); 
}
项目:fr.xs.jtk    文件:Curve2DView.java   
public Curve2DView(int _w, int _h) {
    super();
    displayArea = new BoundingBox(0, -1, 1, 1);

    setPrefSize(_w, _h);

    canvas = new Canvas(_w, _h);
    gc2 = canvas.getGraphicsContext2D();

    getChildren().addAll(canvas);
}