本文整理汇总了Java中javafx.geometry.BoundingBox类的典型用法代码示例。如果您正苦于以下问题:Java BoundingBox类的具体用法?Java BoundingBox怎么用?Java BoundingBox使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
BoundingBox类属于javafx.geometry包,在下文中一共展示了BoundingBox类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: redraw
import javafx.geometry.BoundingBox; //导入依赖的package包/类
@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();
}
示例2: isInWindow
import javafx.geometry.BoundingBox; //导入依赖的package包/类
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();
}
示例3: createCompositeObservableBoundsWithValidBounds
import javafx.geometry.BoundingBox; //导入依赖的package包/类
@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);
}
示例4: refreshContainer
import javafx.geometry.BoundingBox; //导入依赖的package包/类
/** 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));
}
示例5: setupResizer
import javafx.geometry.BoundingBox; //导入依赖的package包/类
/** 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));
}
示例6: validWidth
import javafx.geometry.BoundingBox; //导入依赖的package包/类
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;
}
示例7: validHeight
import javafx.geometry.BoundingBox; //导入依赖的package包/类
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;
}
示例8: translateCameraToCanvas
import javafx.geometry.BoundingBox; //导入依赖的package包/类
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);
}
示例9: translateCanvasToCamera
import javafx.geometry.BoundingBox; //导入依赖的package包/类
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);
}
示例10: testPS3EyeHardwareDefaultsBrightRoomLimitedBounds
import javafx.geometry.BoundingBox; //导入依赖的package包/类
@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);
}
示例11: testPS3EyeHardwareDefaultsRedLaserRoomLightOnSafariLimitedBounds
import javafx.geometry.BoundingBox; //导入依赖的package包/类
@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);
}
示例12: testTwo
import javafx.geometry.BoundingBox; //导入依赖的package包/类
@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);
}
示例13: testThree
import javafx.geometry.BoundingBox; //导入依赖的package包/类
@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);
}
示例14: testPaperPixelsCalcParams
import javafx.geometry.BoundingBox; //导入依赖的package包/类
@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);
}
示例15: onStateChanged
import javafx.geometry.BoundingBox; //导入依赖的package包/类
/**
* 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);
}
}