本文整理汇总了Java中javafx.scene.transform.Translate类的典型用法代码示例。如果您正苦于以下问题:Java Translate类的具体用法?Java Translate怎么用?Java Translate使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Translate类属于javafx.scene.transform包,在下文中一共展示了Translate类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: maxScale
import javafx.scene.transform.Translate; //导入依赖的package包/类
private List<Point2D> maxScale(List<Point2D> points, double factor) {
List<Point2D> scaledList = new ArrayList<>();
if (!drawPath.getElements().isEmpty()) {
// scale and center
Bounds b0 = drawPath.getBoundsInParent();
if (b0.getWidth() > 0 && b0.getHeight() > 0) {
final double w = drawPane.getWidth() - 2 * factor * MARGIN;
final double h = drawPane.getHeight() - 2 * factor * MARGIN;
final double scale = Math.min(w / b0.getWidth(), h / b0.getHeight());
affine = new Affine(new Scale(scale, scale, factor * MARGIN, factor * MARGIN));
affine.append(new Translate(factor * MARGIN - b0.getMinX() + (w - scale * b0.getWidth()) / 2d / scale,
factor * MARGIN - b0.getMinY() + (h - scale * b0.getHeight()) / 2d / scale));
for (Point2D p : points) {
scaledList.add(affine.transform(p));
}
}
}
return scaledList;
}
示例2: Scene3D
import javafx.scene.transform.Translate; //导入依赖的package包/类
public Scene3D(Parent parent, double width, double height) {
// super(new Group(parent), width, height, true); // see http://javafx-jira.kenai.com/browse/RT-22696
super(new Group(parent), width, height);
if (true == Platform.isSupported(ConditionalFeature.SCENE3D)) {
setCamera(new PerspectiveCamera());
Translate centerTranslate = new Translate();
centerTranslate.xProperty().bind(widthProperty().divide(2));
centerTranslate.yProperty().bind(heightProperty().divide(2));
getRoot().getTransforms().addAll(centerTranslate, translateZ, rotateX, rotateY, translateY);
// getRoot().setDepthTest(DepthTest.ENABLE);// see http://javafx-jira.kenai.com/browse/RT-22696
}
}
示例3: bindCoords
import javafx.scene.transform.Translate; //导入依赖的package包/类
private void bindCoords() {
final DoubleExpression radius = model.sizeProperty().multiply(0.5);
final Translate translation = new Translate();
translation.xProperty().bind(transformRadius);
final Rotate rotation = new Rotate();
rotation.pivotXProperty().bind(transformRadius.subtract(radius).multiply(-1));
rotation.pivotYProperty().bind(radius);
rotation.angleProperty().bind(transformAngle);
button.getTransforms().addAll(translation, rotation);
final Rotate twist = new Rotate();
twist.pivotXProperty().bind(radius);
twist.pivotYProperty().bind(radius);
twist.angleProperty().bind(transformAngle.multiply(-1.0d));
button.getTransforms().add(twist);
model.visibleProperty().addListener((observable) -> {
updateVisibility();
});
}
示例4: setBossBar
import javafx.scene.transform.Translate; //导入依赖的package包/类
public void setBossBar(Entity boss) {
getChildren().remove(bossHealthBar);
bossHealthBar = new ValueBar(95, 20, boss.<Enemy>getProperty(Property.DATA).curHealth, boss.<Enemy>getProperty(Property.DATA).maxHealth, Color.YELLOW);
bossHealthBar.getTransforms().add(new Rotate(270));
bossHealthBar.getTransforms().add(new Translate(-10, 580, 0));
boss.<Enemy>getProperty(Property.DATA).curHealth.addListener(new ChangeListener<Number>() {
@Override
public void changed(ObservableValue<? extends Number> arg0, Number arg1, Number arg2) {
if (arg2.intValue() <= 0) {
FadeTransition ft = new FadeTransition(Duration.seconds(1), bossHealthBar);
ft.setFromValue(1);
ft.setToValue(0);
ft.setOnFinished((event) -> bossHealthBar.setVisible(false));
ft.play();
}
}
});
getChildren().add(bossHealthBar);
}
示例5: makePedestal
import javafx.scene.transform.Translate; //导入依赖的package包/类
private void makePedestal(ObservableList<Node> g) {
// pedestal
Box box = new Box(5.5, 0.2, 5);
box.setMaterial(material2);
// box.setTranslateY(3);
double length1 = 4.2;
// outlet dispatch tube
Capsule t1 = new Capsule(0.3, length1);
t1.setCullFace(CullFace.BACK);
t1.setMaterial(material);
t1.getTransforms().addAll(new Rotate(90, X_AXIS), new Translate(0, -length1 / 2, -0.4));
double length2 = 4.4;
// outlet endpoint supply tube
Group tg = makePump(length2, 0.3, 0.35, material);
tg.getTransforms().addAll(new Rotate(90, X_AXIS), new Translate(-2.8, 0, -1.5));
g.addAll(t1, tg, box);
// TriangleMesh mesh = createToroidMesh(2f, 0.5f, 100, 100);
// g.addAll(new MeshView(mesh));
}
示例6: Bone
import javafx.scene.transform.Translate; //导入依赖的package包/类
public Bone(double scale, Point3D posJoint) {
Box origin=new Box(10,10,10);
origin.setMaterial(new PhongMaterial(Color.ORANGE));
Cylinder bone = new Cylinder(5, posJoint.magnitude()/scale);
double angle = Math.toDegrees(Math.acos((new Point3D(0,1,0)).dotProduct(posJoint)/posJoint.magnitude()));
Point3D axis = (new Point3D(0,1,0)).crossProduct(posJoint);
bone.getTransforms().addAll(new Rotate(angle,0,0,0,axis), new Translate(0,posJoint.magnitude()/2d/scale, 0));
bone.setMaterial(new PhongMaterial(Color.CADETBLUE));
Sphere end = new Sphere(6);
end.getTransforms().addAll(new Translate(posJoint.getX()/scale,posJoint.getY()/scale,posJoint.getZ()/scale));
end.setMaterial(new PhongMaterial(Color.YELLOW));
getChildren().addAll(origin, bone, end);
getTransforms().add(new Scale(scale, scale, scale));
}
示例7: Axes
import javafx.scene.transform.Translate; //导入依赖的package包/类
public Axes(double scale) {
Cylinder axisX = new Cylinder(3, 60);
axisX.getTransforms().addAll(new Rotate(90, Rotate.Z_AXIS), new Translate(0, 30, 0));
axisX.setMaterial(new PhongMaterial(Color.RED));
Cylinder axisY = new Cylinder(3, 60);
axisY.getTransforms().add(new Translate(0, 30, 0));
axisY.setMaterial(new PhongMaterial(Color.GREEN));
Cylinder axisZ = new Cylinder(3, 60);
axisZ.setMaterial(new PhongMaterial(Color.BLUE));
axisZ.getTransforms().addAll(new Rotate(90, Rotate.X_AXIS), new Translate(0, 30, 0));
getChildren().addAll(axisX, axisY, axisZ);
getTransforms().add(new Scale(scale, scale, scale));
}
示例8: toNode
import javafx.scene.transform.Translate; //导入依赖的package包/类
public Node toNode(double zoomLevel, boolean infraredOn, boolean effectsOn) {
if (zoomLevel < MINIMUM_ZOOM_LEVEL)
return null;
waveAngle = Angle.normalize(waveAngle + BLOBBING_SPEED);
shape.setRadiusX(Math.min(getEgg().getAge(), Configuration.EGG_RADIUS + RADIUS_VARIATION * FastMath.sin(waveAngle)));
shape.setRadiusY(Math.min(getEgg().getAge(), Configuration.EGG_RADIUS + RADIUS_VARIATION * FastMath.cos(waveAngle)));
shape.setFill(getFillColor(infraredOn));
if (effectsOn)
shape.setEffect(getEffects(zoomLevel, infraredOn));
shape.getTransforms().clear();
Translate translation = new Translate(getThing().getPosition().x, getThing().getPosition().y);
shape.getTransforms().add(translation);
return shape;
}
示例9: EyesView
import javafx.scene.transform.Translate; //导入依赖的package包/类
public EyesView(Narjillo narjillo) {
this.narjillo = narjillo;
Fiber fiber = narjillo.getBody().getHead().getFiber();
this.eyeRed = fiber.getPercentOfRed();
this.eyeGreen = fiber.getPercentOfGreen();
this.eyeBlue = fiber.getPercentOfBlue();
// "Random qualities": we want something that looks random across narjillos,
// but stays the same for the same narjillo even after saving and reloading
double someRandomQuality = narjillo.getBody().getAdultMass();
double someOtherRandomQuality = narjillo.getBody().getEnergyToChildren();
this.eye1 = new Circle(someRandomQuality % 5 + 7);
this.eye2 = new Circle(someOtherRandomQuality % 5 + 7);
this.pupil1 = new Circle(Math.min(eye1.getRadius() - 2, someRandomQuality % 6 + 1));
this.pupil2 = new Circle(Math.min(eye1.getRadius() - 2, someOtherRandomQuality % 6 + 1));
eyeCenteringTranslation = eye1.getRadius() - eye2.getRadius();
pupilTranslation = Math.min(eye2.getRadius() - pupil2.getRadius(), eye1.getRadius() - pupil1.getRadius());
this.eye1.getTransforms().add(new Translate(eyeCenteringTranslation - eye1.getRadius() + 1, 0));
this.eye2.getTransforms().add(new Translate(eyeCenteringTranslation + eye2.getRadius() - 1, 0));
}
示例10: getShape
import javafx.scene.transform.Translate; //导入依赖的package包/类
private Shape getShape(double zoomLevel, boolean effectsOn) {
segment.setWidth(organ.getLength() + getOverlap() * 2);
segment.setHeight(organ.getThickness());
segment.getTransforms().clear();
// overlap slightly and shift to center based on thickness
double widthCenter = organ.getThickness() / 2;
segment.getTransforms().add(moveToStartPoint());
segment.getTransforms().add(new Translate(-getOverlap(), -widthCenter));
segment.getTransforms().add(new Rotate(organ.getAbsoluteAngle(), getOverlap(), widthCenter));
boolean isHighDetail = hasJoint && zoomLevel >= VERY_HIGH_MAGNIFICATION && effectsOn;
if (!isHighDetail)
return segment;
joint.setRadius(getJointRadius(organ.getThickness()));
joint.getTransforms().clear();
joint.getTransforms().add(moveToStartPoint());
joint.getTransforms().add(new Translate(organ.getLength(), 0));
joint.getTransforms().add(new Rotate(organ.getAbsoluteAngle(), -organ.getLength(), 0));
return Path.union(segment, joint);
}
示例11: toNode
import javafx.scene.transform.Translate; //导入依赖的package包/类
@Override
public Node toNode(double zoomLevel, boolean infraredOn, boolean effectsOn) {
if (zoomLevel < MINIMUM_ZOOM_LEVEL)
return null;
Color color = getColor(zoomLevel, infraredOn);
for (int i = 0; i < lines.length; i++) {
lines[i].setStroke(color);
rotateLine(i);
}
Vector position = getNarjillo().getPosition();
group.getTransforms().clear();
group.getTransforms().add(new Translate(position.x, position.y));
return group;
}
示例12: init
import javafx.scene.transform.Translate; //导入依赖的package包/类
private void init(Stage primaryStage) {
Group root = new Group();
root.setDepthTest(DepthTest.ENABLE);
primaryStage.setResizable(false);
primaryStage.setScene(new Scene(root, 400, 150, true));
primaryStage.getScene().setCamera(new PerspectiveCamera());
root.getTransforms().addAll(
new Translate(400 / 2, 150 / 2),
new Rotate(180, Rotate.X_AXIS)
);
root.getChildren().add(create3dContent());
}
示例13: init
import javafx.scene.transform.Translate; //导入依赖的package包/类
private void init(Stage primaryStage) {
Group root = new Group();
root.setDepthTest(DepthTest.ENABLE);
primaryStage.setResizable(false);
primaryStage.setScene(new Scene(root, 500, 500, true));
primaryStage.getScene().setCamera(new PerspectiveCamera());
root.getTransforms().addAll(
new Translate(500 / 2, 500 / 2),
new Rotate(180, Rotate.X_AXIS)
);
root.getChildren().add(create3dContent());
}
示例14: init
import javafx.scene.transform.Translate; //导入依赖的package包/类
private void init(Stage primaryStage) {
Group root = new Group();
root.setDepthTest(DepthTest.ENABLE);
primaryStage.setResizable(false);
primaryStage.setScene(new Scene(root, 400, 500, true));
primaryStage.getScene().setCamera(new PerspectiveCamera());
root.getTransforms().addAll(
new Translate(400 / 2, 500 / 2 + 100),
new Rotate(180, Rotate.X_AXIS)
);
root.getChildren().add(create3dContent());
}
示例15: Sample3D
import javafx.scene.transform.Translate; //导入依赖的package包/类
protected Sample3D(double width, double height) {
super(width, height);
Group group3d = new Group(create3dContent());
group3d.setDepthTest(DepthTest.ENABLE);
group3d.getTransforms().addAll(
new Translate(width / 2, height / 2),
new Rotate(180, Rotate.X_AXIS)
);
getChildren().add(group3d);
}