本文整理汇总了Java中javafx.scene.Camera类的典型用法代码示例。如果您正苦于以下问题:Java Camera类的具体用法?Java Camera怎么用?Java Camera使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Camera类属于javafx.scene包,在下文中一共展示了Camera类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: checkCamera
import javafx.scene.Camera; //导入依赖的package包/类
/**
* Check that the camera is added to the parent INode's JavaFX node
* correctly.
*/
@Test
public void checkCamera() {
// Create a camera, an attachment containing that camera, and the node
Camera camera = new PerspectiveCamera();
FXCameraAttachment attachment = new FXCameraAttachment(camera);
GNode node = new GNode();
Group fxNode = new Group();
node.setProperty(INode.RENDERER_NODE_PROP, fxNode);
// Check that the attachment has the camera
assertTrue(attachment.getFxCamera() == camera);
// Attach to the node and check that the camera has been added to the
// JavaFX node
attachment.attach(node);
assertTrue(Util.getFxGroup(node).getChildren().contains(camera));
// Detach from the node and check that the camera has been removed from
// the JavaFX node.
attachment.detach(node);
assertFalse(Util.getFxGroup(node).getChildren().contains(camera));
}
示例2: updateCamera
import javafx.scene.Camera; //导入依赖的package包/类
/**
* @see BasicViewer#updateCamera(ICamera)
*/
@Override
protected void updateCamera(ICamera camera) {
if (!(camera instanceof FXCameraAttachment)) {
throw new IllegalArgumentException(
Messages.FXGeometryViewer_InvalidCamera);
}
FXCameraAttachment attachment = (FXCameraAttachment) camera;
Camera fxCamera = attachment.getFxCamera();
if (fxCamera == null) {
throw new NullPointerException(
Messages.FXGeometryViewer_NullCamera);
}
cameraController = new CenteredCameraController(fxCamera, scene,
fxCanvas);
scene.setCamera(fxCamera);
defaultCamera = fxCamera;
}
示例3: CenteredCameraController
import javafx.scene.Camera; //导入依赖的package包/类
/**
* The default constructor.
*
* @param camera
* The camera this controller will manage.
* @param scene
* The scene the camera is viewing.
* @param canvas
* The FXCanvas containing the scene.
*/
public CenteredCameraController(Camera camera, Scene scene,
FXCanvas canvas) {
super(camera, scene, canvas);
// Initialize the data members
dragStarted = false;
shouldInvertX = false;
shouldInvertY = false;
// Set the x axis rotation for the affine transformation
x = new Rotate();
x.setAxis(Rotate.X_AXIS);
// Set the y axis rotation for the affine transformation
y = new Rotate();
y.setAxis(Rotate.Y_AXIS);
// Set the y axis rotation for the affine transformation
z = new Rotate();
z.setAxis(Rotate.Z_AXIS);
// Apply the rotations and the affine to the camera
xform.getTransforms().setAll(x, y, z, affine);
}
示例4: updateCamera
import javafx.scene.Camera; //导入依赖的package包/类
@Override
protected void updateCamera(ICamera camera) {
if (!(camera instanceof FXCameraAttachment)) {
throw new IllegalArgumentException(
"Invalid camera attached to Mesh Viewer.");
}
FXCameraAttachment attachment = (FXCameraAttachment) camera;
Camera fxCamera = attachment.getFxCamera();
if (fxCamera == null) {
throw new NullPointerException(
"No camera was attached to Mesh Viewer");
}
cameraController = new TopDownCameraController(fxCamera, scene,
fxCanvas);
// scene.setCamera(fxCamera);
scene.setCamera(null);
subScene.setCamera(fxCamera);
defaultCamera = fxCamera;
}
示例5: calculateEdgeAngle
import javafx.scene.Camera; //导入依赖的package包/类
/**
* Calculates the angle needed for the given {@link Node} to be edge-on with
* the user.
*
* @param pNode the {@link Node}.
* @param pOrientation the {@link Orientation}.
* @return the angle needed for the {@link Node} the be viewed edge-on.
*/
public static double calculateEdgeAngle(Node pNode, Orientation pOrientation)
{
Scene scene = pNode.getScene();
Camera camera = scene.getCamera();
if (camera instanceof PerspectiveCamera)
{
PerspectiveCamera perspectiveCamera = (PerspectiveCamera)camera;
double distanceFromCenter = getDistanceFromCenter(scene, pNode, pOrientation);
double rotationFromCenter = getAngleFromCenter(scene, perspectiveCamera, distanceFromCenter);
return 90 - rotationFromCenter;
}
return 90;
}
示例6: addCamera
import javafx.scene.Camera; //导入依赖的package包/类
@Override
protected Camera addCamera(Scene scene) {
camera = cam = new PerspectiveCamera(true);
scene.setCamera(camera);
camera.setFarClip(10000);
return camera;
}
示例7: addCamera
import javafx.scene.Camera; //导入依赖的package包/类
@Override
protected Camera addCamera(SubScene scene) {
PerspectiveCamera pc = new PerspectiveCamera(true);
scene.setCamera(pc);
pc.setFarClip(10000);
return pc;
}
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:8,代码来源:SubScenePerspectiveCameraFixedEyeIsolateTestApp.java
示例8: updateCamera
import javafx.scene.Camera; //导入依赖的package包/类
@Override
protected void updateCamera(ICamera camera) {
// Check the camera attachment for validity
if (!(camera instanceof FXCameraAttachment)) {
throw new IllegalArgumentException(
"Invalid camera attached to Mesh Viewer.");
}
// Cast the camera attachment and check that it has a camera
FXCameraAttachment attachment = (FXCameraAttachment) camera;
Camera fxCamera = attachment.getFxCamera();
if (fxCamera == null) {
throw new NullPointerException(
"No camera was attached to Mesh Viewer");
}
// Create a controller
cameraController = new CenteredCameraController(fxCamera, scene,
fxCanvas);
// Set the camera on the scene
scene.setCamera(null);
subScene.setCamera(fxCamera);
defaultCamera = fxCamera;
}
示例9: testGetCameraAdjuster
import javafx.scene.Camera; //导入依赖的package包/类
@Test
public void testGetCameraAdjuster() {
Adjuster adjuster = Adjuster.getAdjuster(Camera.class);
assertThat(adjuster, is(instanceOf(NodeAdjuster.class)));
assertThat(adjuster.getNodeClass(), is(sameInstance(Node.class)));
}
示例10: animateHide
import javafx.scene.Camera; //导入依赖的package包/类
@Override
protected void animateHide(Runnable onFinishedHandler) {
if (autoCloseTimer != null) {
autoCloseTimer.stop();
autoCloseTimer = null;
}
if (NotificationCenter.useAnimations) {
double duration = getDuration(400);
Interpolator interpolator = Interpolator.SPLINE(0.25, 0.1, 0.25, 1);
gridPane.setRotationAxis(Rotate.X_AXIS);
Camera camera = gridPane.getScene().getCamera();
gridPane.getScene().setCamera(new PerspectiveCamera());
Timeline timeline = new Timeline();
ObservableList<KeyFrame> keyFrames = timeline.getKeyFrames();
keyFrames.add(new KeyFrame(Duration.millis(0),
new KeyValue(gridPane.rotateProperty(), 0, interpolator),
new KeyValue(gridPane.opacityProperty(), 1, interpolator)
));
keyFrames.add(new KeyFrame(Duration.millis(duration),
new KeyValue(gridPane.rotateProperty(), -90, interpolator),
new KeyValue(gridPane.opacityProperty(), 0, interpolator)
));
timeline.setOnFinished(event -> {
gridPane.setRotate(0);
gridPane.setRotationAxis(Rotate.Z_AXIS);
gridPane.getScene().setCamera(camera);
onFinishedHandler.run();
});
timeline.play();
} else {
onFinishedHandler.run();
}
}
示例11: animateHide
import javafx.scene.Camera; //导入依赖的package包/类
@Override
protected void animateHide(Runnable onFinishedHandler) {
if (GlobalSettings.getUseAnimations()) {
double duration = getDuration(300);
Interpolator interpolator = Interpolator.SPLINE(0.25, 0.1, 0.25, 1);
gridPane.setRotationAxis(Rotate.X_AXIS);
Camera camera = gridPane.getScene().getCamera();
gridPane.getScene().setCamera(new PerspectiveCamera());
Timeline timeline = new Timeline();
ObservableList<KeyFrame> keyFrames = timeline.getKeyFrames();
keyFrames.add(new KeyFrame(Duration.millis(0),
new KeyValue(gridPane.rotateProperty(), 0, interpolator),
new KeyValue(gridPane.opacityProperty(), 1, interpolator)
));
keyFrames.add(new KeyFrame(Duration.millis(duration),
new KeyValue(gridPane.rotateProperty(), -90, interpolator),
new KeyValue(gridPane.opacityProperty(), 0, interpolator)
));
timeline.setOnFinished(event -> {
gridPane.setRotate(0);
gridPane.setRotationAxis(Rotate.Z_AXIS);
gridPane.getScene().setCamera(camera);
onFinishedHandler.run();
});
timeline.play();
} else {
onFinishedHandler.run();
}
}
示例12: buildCamera
import javafx.scene.Camera; //导入依赖的package包/类
@Override
protected Camera buildCamera() {
PerspectiveCamera cam = new PerspectiveCamera(true);
cam.setFarClip(SCALE * 30);
return cam;
}
示例13: buildCamera
import javafx.scene.Camera; //导入依赖的package包/类
@Override
protected Camera buildCamera() {
PerspectiveCamera cam = new PerspectiveCamera(true);
cam.setFarClip(SCALE * 25);
return cam;
}
示例14: buildCamera
import javafx.scene.Camera; //导入依赖的package包/类
@Override
protected Camera buildCamera() {
return new PerspectiveCamera();
}
示例15: buildCamera
import javafx.scene.Camera; //导入依赖的package包/类
@Override
protected Camera buildCamera() {
return new ParallelCamera();
}