java类javafx.geometry.BoundingBox的实例源码

MapCanvas.java 文件源码 项目:HTWK_Visu 阅读 32 收藏 0 点赞 0 评论 0
@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();
}
RelativeMouse.java 文件源码 项目:openjfx-8u-dev-tests 阅读 17 收藏 0 点赞 0 评论 0
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();
}
CompositeObservableBoundsTest.java 文件源码 项目:j.commons 阅读 21 收藏 0 点赞 0 评论 0
@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);

}
Block.java 文件源码 项目:viskell 阅读 29 收藏 0 点赞 0 评论 0
/** 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));
}
Lane.java 文件源码 项目:viskell 阅读 20 收藏 0 点赞 0 评论 0
/** 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));
}
JFXMasonryPane.java 文件源码 项目:JFoenix 阅读 22 收藏 0 点赞 0 评论 0
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;
}
JFXMasonryPane.java 文件源码 项目:JFoenix 阅读 22 收藏 0 点赞 0 评论 0
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;
}
CanvasManager.java 文件源码 项目:ShootOFF 阅读 22 收藏 0 点赞 0 评论 0
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);
}
CanvasManager.java 文件源码 项目:ShootOFF 阅读 22 收藏 0 点赞 0 评论 0
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);
}
TestCameraManagerDark.java 文件源码 项目:ShootOFF 阅读 19 收藏 0 点赞 0 评论 0
@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);
}
TestCameraManagerDark.java 文件源码 项目:ShootOFF 阅读 23 收藏 0 点赞 0 评论 0
@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);
}
TestPerspectiveManager.java 文件源码 项目:ShootOFF 阅读 24 收藏 0 点赞 0 评论 0
@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);
}
TestPerspectiveManager.java 文件源码 项目:ShootOFF 阅读 18 收藏 0 点赞 0 评论 0
@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);
}
TestPerspectiveManager.java 文件源码 项目:ShootOFF 阅读 25 收藏 0 点赞 0 评论 0
@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);
}
FXInternalWindow.java 文件源码 项目:JVx.javafx 阅读 19 收藏 0 点赞 0 评论 0
/**
 * 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);
    }
}
FXBorderPane.java 文件源码 项目:JVx.javafx 阅读 22 收藏 0 点赞 0 评论 0
/**
 * {@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);
}
PointPairTest.java 文件源码 项目:contentment 阅读 22 收藏 0 点赞 0 评论 0
@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);
    }
}
GenericStyledArea.java 文件源码 项目:RichTextFX 阅读 21 收藏 0 点赞 0 评论 0
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));
}
GenericStyledArea.java 文件源码 项目:RichTextFX 阅读 21 收藏 0 点赞 0 评论 0
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);
}
GesturePaneTest.java 文件源码 项目:GestureFX 阅读 21 收藏 0 点赞 0 评论 0
@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));
}
MathFunctions.java 文件源码 项目:fx-animation-editor 阅读 28 收藏 0 点赞 0 评论 0
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);
}
DropOp.java 文件源码 项目:FxDock 阅读 21 收藏 0 点赞 0 评论 0
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);
}
DropOp.java 文件源码 项目:FxDock 阅读 22 收藏 0 点赞 0 评论 0
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);
}
CompositeObservableBoundsTest.java 文件源码 项目:j.commons 阅读 23 收藏 0 点赞 0 评论 0
@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);
}
CompositeObservableBoundsTest.java 文件源码 项目:j.commons 阅读 20 收藏 0 点赞 0 评论 0
@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);
}
HitBox.java 文件源码 项目:FXGL 阅读 20 收藏 0 点赞 0 评论 0
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");
    }
}
BlockContainer.java 文件源码 项目:viskell 阅读 33 收藏 0 点赞 0 评论 0
/** 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);
}
ToplevelPane.java 文件源码 项目:viskell 阅读 19 收藏 0 点赞 0 评论 0
/**
 * @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;
}
Lane.java 文件源码 项目:viskell 阅读 26 收藏 0 点赞 0 评论 0
@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);
}
Lane.java 文件源码 项目:viskell 阅读 26 收藏 0 点赞 0 评论 0
@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));
}


问题


面经


文章

微信
公众号

扫码关注公众号