本文整理汇总了Java中javafx.geometry.Dimension2D类的典型用法代码示例。如果您正苦于以下问题:Java Dimension2D类的具体用法?Java Dimension2D怎么用?Java Dimension2D使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Dimension2D类属于javafx.geometry包,在下文中一共展示了Dimension2D类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: setFillImageKeepingAspectRatio
import javafx.geometry.Dimension2D; //导入依赖的package包/类
public void setFillImageKeepingAspectRatio(Rectangle rectangle, Image image, Dimension2D gamingContextDimension2D) {
double imageWidth = image.getWidth();
double imageHeight = image.getHeight();
double imageHeightToWidthRatio = imageHeight / imageWidth;
double initialHeight = rectangle.getHeight();
double initialWidth = initialHeight / imageHeightToWidthRatio;
double positionX = (gamingContextDimension2D.getWidth() - initialWidth) / 2;
double positionY = (gamingContextDimension2D.getHeight() - initialHeight) / 2;
rectangle.setFill(new ImagePattern(image));
rectangle.setX(positionX);
rectangle.setY(positionY);
rectangle.setWidth(initialWidth);
rectangle.setHeight(initialHeight);
rectangle.setTranslateX(0);
rectangle.setScaleX(1);
rectangle.setScaleY(1);
rectangle.setScaleZ(1);
}
示例2: newRandomPosition
import javafx.geometry.Dimension2D; //导入依赖的package包/类
public Position newRandomPosition(double radius) {
double minX = radius;
double minY = radius;
Dimension2D dimension2D = getDimension2D();
double maxX = dimension2D.getWidth() - radius;
double maxY = dimension2D.getHeight() - radius;
if (maxX > 0 && maxY > 0) {
double positionX = random.nextInt((int) (maxX - minX)) + minX;
double positionY = random.nextInt((int) (maxY - minY)) + minY;
return new Position((int) positionX, (int) positionY);
} else {
return new Position((int) radius, (int) radius);
}
}
示例3: latLongToPixel
import javafx.geometry.Dimension2D; //导入依赖的package包/类
public static Point2D latLongToPixel(final Dimension2D MAP_DIMENSION,
final Point2D UPPER_LEFT,
final Point2D LOWER_RIGHT,
final Point2D LOCATION) {
final double LATITUDE = LOCATION.getX();
final double LONGITUDE = LOCATION.getY();
final double MAP_WIDTH = MAP_DIMENSION.getWidth();
final double MAP_HEIGHT = MAP_DIMENSION.getHeight();
final double WORLD_MAP_WIDTH = ((MAP_WIDTH / (LOWER_RIGHT.getY() - UPPER_LEFT.getY())) * 360) / (2 * Math.PI);
final double MAP_OFFSET_Y = (WORLD_MAP_WIDTH / 2 * Math.log10((1 + Math.sin(Math.toRadians(LOWER_RIGHT.getX()))) / (1 - Math.sin(Math.toRadians(LOWER_RIGHT.getX())))));
final double X = (LONGITUDE - UPPER_LEFT.getY()) * (MAP_WIDTH / (LOWER_RIGHT.getY() - UPPER_LEFT.getY()));
final double Y = MAP_HEIGHT - ((WORLD_MAP_WIDTH / 2 * Math.log10((1 + Math.sin(Math.toRadians(LATITUDE))) / (1 - Math.sin(Math.toRadians(LATITUDE))))) - MAP_OFFSET_Y);
return new Point2D(X, Y);
}
示例4: chain
import javafx.geometry.Dimension2D; //导入依赖的package包/类
/**
* Constructs new closed chain shaped bounding shape.
* Note: chain shape can only be used with static objects.
* Note: chain shape must have at least 2 points
*
* @param points points to use in a chain
* @return closed chain bounding shape
* @throws IllegalArgumentException if number of points is less than 2
*/
public static BoundingShape chain(Point2D... points) {
if (points.length < 2)
throw new IllegalArgumentException("Chain shape requires at least 2 points. Given points: " + points.length);
double maxX = Stream.of(points)
.mapToDouble(Point2D::getX)
.max()
.getAsDouble();
double maxY = Stream.of(points)
.mapToDouble(Point2D::getY)
.max()
.getAsDouble();
return new BoundingShape(ShapeType.CHAIN, points, new Dimension2D(maxX, maxY));
}
示例5: moveTarget
import javafx.geometry.Dimension2D; //导入依赖的package包/类
public void moveTarget() {
if (maxVelocity == 0) return;
final Bounds b = target.getBoundsInParent();
final Point2D p = target.getPosition();
final Dimension2D d = target.getDimension();
final CollisionType ct = checkCollision();
if (b.getMinX() <= 1 || b.getMinX() + d.getWidth() > thisSuper.getArenaWidth()
|| ct == CollisionType.COLLISION_X || ct == CollisionType.COLLISION_BOTH) {
dx *= -1;
}
if (b.getMinY() <= 1 || b.getMinY() + d.getHeight() > thisSuper.getArenaHeight()
|| ct == CollisionType.COLLISION_X || ct == CollisionType.COLLISION_BOTH) {
dy *= -1;
}
target.setPosition(p.getX() + dx, p.getY() + dy);
}
示例6: autoCalibrateSuccess
import javafx.geometry.Dimension2D; //导入依赖的package包/类
protected void autoCalibrateSuccess(Bounds arenaBounds, Optional<Dimension2D> paperDims, long delay) {
if (isAutoCalibrating.get() && cameraCalibrationListener != null) {
isAutoCalibrating.set(false);
logger.debug("autoCalibrateSuccess {} {} {} {} paper {}", (int) arenaBounds.getMinX(),
(int) arenaBounds.getMinY(), (int) arenaBounds.getWidth(), (int) arenaBounds.getHeight(),
paperDims.isPresent());
cameraAutoCalibrated = true;
cameraCalibrationListener.calibrate(arenaBounds, paperDims, false, delay);
if (recordCalibratedArea && !recordingCalibratedArea)
startRecordingCalibratedArea(new File("calibratedArea.mp4"), (int) arenaBounds.getWidth(),
(int) arenaBounds.getHeight());
}
}
示例7: testTwo
import javafx.geometry.Dimension2D; //导入依赖的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);
}
示例8: testThree
import javafx.geometry.Dimension2D; //导入依赖的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);
}
示例9: setDistance
import javafx.geometry.Dimension2D; //导入依赖的package包/类
private void setDistance() {
if (!validateDistanceData()) return;
persistSettings();
final int width = Integer.parseInt(targetWidth.getText());
final int height = Integer.parseInt(targetHeight.getText());
final int distance = Integer.parseInt(targetDistance.getText());
if (logger.isTraceEnabled()) {
logger.trace(
"New target settings from distance settings pane: current width = {}, "
+ "default height = {}, default distance = {}, new distance = {}",
width, height, originalTargetDistance, distance);
}
final Optional<Dimension2D> targetDimensions = perspectiveManager.calculateObjectSize(width, height, distance);
if (targetDimensions.isPresent()) {
final Dimension2D d = targetDimensions.get();
target.setDimensions(d.getWidth(), d.getHeight());
}
}
示例10: PerspectiveManager
import javafx.geometry.Dimension2D; //导入依赖的package包/类
public PerspectiveManager(Bounds arenaBounds, Dimension2D feedDims, Dimension2D paperBounds,
Dimension2D projectorRes) {
this(arenaBounds);
setCameraFeedSize((int) feedDims.getWidth(), (int) feedDims.getHeight());
this.setProjectorResolution(projectorRes);
setProjectionSizeFromLetterPaperPixels(paperBounds);
if (cameraDistance == -1)
cameraDistance = DEFAULT_SHOOTER_DISTANCE;
if (shooterDistance == -1)
shooterDistance = DEFAULT_SHOOTER_DISTANCE;
calculateRealWorldSize();
}
示例11: testPaperPixelsCalcParams
import javafx.geometry.Dimension2D; //导入依赖的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);
}
示例12: getSize
import javafx.geometry.Dimension2D; //导入依赖的package包/类
public Dimension2D getSize() {
return EventQueueWait.exec(new Callable<Dimension2D>() {
@Override public Dimension2D call() throws Exception {
return new Dimension2D(currentWindow.getWidth(), currentWindow.getHeight());
}
});
}
示例13: getSymbolSize
import javafx.geometry.Dimension2D; //导入依赖的package包/类
public Dimension2D getSymbolSize(final Series<X, Y> SERIES) {
if (!getData().contains(SERIES)) { return new Dimension2D(0, 0); }
if (SERIES.getData().isEmpty()) { return new Dimension2D(0, 0); }
for (XYChart.Data<X, Y> data : SERIES.getData()) {
StackPane stackPane = (StackPane) data.getNode();
if (null == stackPane) {
continue;
} else {
return new Dimension2D(stackPane.getLayoutBounds().getWidth(), stackPane.getLayoutBounds().getHeight());
}
}
return new Dimension2D(0, 0);
}
示例14: setHiddenPicture
import javafx.geometry.Dimension2D; //导入依赖的package包/类
private void setHiddenPicture(GameContext gameContext) {
final int randomPictureIndex = (int) Math.floor(Math.random() * images.length);
final Image randomPicture = images[randomPictureIndex];
Dimension2D dimension2D = gameContext.getGamePanelDimensionProvider().getDimension2D();
Rectangle imageRectangle = new Rectangle(0, 0, dimension2D.getWidth(), dimension2D.getHeight());
imageRectangle.setFill(new ImagePattern(randomPicture, 0, 0, 1, 1, true));
AspectRatioImageRectangleUtil aspectRatioImageRectangleUtil = new AspectRatioImageRectangleUtil();
aspectRatioImageRectangleUtil.setFillImageKeepingAspectRatio(imageRectangle, randomPicture, dimension2D);
gameContext.getChildren().add(imageRectangle);
}
示例15: launch
import javafx.geometry.Dimension2D; //导入依赖的package包/类
@Override
public void launch() {
this.currentRoundDetails = new CurrentRoundDetails(initCount, nbLines, nbColomns);
javafx.geometry.Dimension2D dimension2D = gameContext.getGamePanelDimensionProvider().getDimension2D();
setHiddenPicture(gameContext);
double width = dimension2D.getWidth() / nbColomns;
double height = dimension2D.getHeight() / nbLines;
for (int i = 0; i < nbColomns; i++)
for (int j = 0; j < nbLines; j++) {
Bloc bloc = new Bloc(i * width, j * height, width + 1, height + 1, i, j);// width+1, height+1 to avoid
// spaces between blocks for
// Scratchcard
if (colors)
bloc.setFill(new Color(Math.random(), Math.random(), Math.random(), 1));
else
bloc.setFill(Color.BLACK);
gameContext.getChildren().add(bloc);
currentRoundDetails.blocs[i][j] = bloc;
bloc.toFront();
GazeUtils.addEventFilter(bloc);
bloc.addEventFilter(MouseEvent.ANY, enterEvent);
bloc.addEventFilter(GazeEvent.ANY, enterEvent);
stats.start();
}
}