本文整理汇总了Java中javafx.scene.shape.Cylinder.setTranslateY方法的典型用法代码示例。如果您正苦于以下问题:Java Cylinder.setTranslateY方法的具体用法?Java Cylinder.setTranslateY怎么用?Java Cylinder.setTranslateY使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.shape.Cylinder
的用法示例。
在下文中一共展示了Cylinder.setTranslateY方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildMultipleShapes3D
import javafx.scene.shape.Cylinder; //导入方法依赖的package包/类
private Group buildMultipleShapes3D() {
Box box = new Box(100, 100, 100);
Sphere sphere = new Sphere(50);
Cylinder cyl = new Cylinder(50, 100);
Cone cone = new Cone(50, 100);
box.setTranslateX(-100);
box.setTranslateY(-150);
sphere.setTranslateX(100);
sphere.setTranslateY(-50);
cyl.setTranslateX(-100);
cyl.setTranslateY(50);
cone.getMesh().setTranslateX(100);
cone.getMesh().setTranslateY(150);
nodes.add(box);
nodes.add(sphere);
nodes.add(cyl);
nodes.add(cone.getMesh());
return new Group(box, sphere, cyl, cone.getMesh());
}
示例2: createCylinderConnecting
import javafx.scene.shape.Cylinder; //导入方法依赖的package包/类
private Cylinder createCylinderConnecting(Vector3D source, Vector3D target) {
Vector3D delta = target.subtract(source);
double distance = source.distanceTo(target);
Cylinder bond = new Cylinder(0.4, distance, 10);
Vector3D newLocation = delta.divide(2).add(source);
bond.setTranslateX(newLocation.getX());
bond.setTranslateY(newLocation.getY());
bond.setTranslateZ(newLocation.getZ());
// phi
bond.getTransforms().add(new Rotate(90 + Math.toDegrees(Math.atan2(delta.getY(), delta.getX())), Rotate.Z_AXIS));
// theta
bond.getTransforms().add(new Rotate(90 + Math.toDegrees(Math.acos(delta.getZ() / distance)), Rotate.X_AXIS));
return bond;
}
示例3: makeBaseTube
import javafx.scene.shape.Cylinder; //导入方法依赖的package包/类
private Group makeBaseTube(double height, double r1, double r2) {
// horizontal tube with heads
double half = height / 2;
Cylinder t0 = new Cylinder(r1, height);
Cylinder t1 = new Cylinder(r2, 0.12);
Cylinder t2 = new Cylinder(r2, 0.12);
Cylinder t3 = new Cylinder(r2, 0.12);
Cylinder t4 = new Cylinder(r2, 0.12);
t0.setMaterial(material);
t1.setMaterial(material);
t2.setMaterial(material);
t3.setMaterial(material);
t4.setMaterial(material);
t1.setTranslateY(half + 0.13);
t2.setTranslateY(half);
t3.setTranslateY(-half + 0.7);
t4.setTranslateY(-half + 0.57);
return new Group(t0, t1, t2, t3, t4);
}
示例4: buildMultipleShapes
import javafx.scene.shape.Cylinder; //导入方法依赖的package包/类
private Group buildMultipleShapes() {
Box box = new Box(100, 100, 100);
Sphere sphere = new Sphere(50);
Cylinder cyl = new Cylinder(50, 100);
Cone cone = new Cone(50, 100);
Rectangle rect = new Rectangle(50, 50);
rect.setFill(Color.WHITESMOKE);
box.setTranslateX(-100);
box.setTranslateY(-150);
sphere.setTranslateX(100);
sphere.setTranslateY(-50);
cyl.setTranslateX(-100);
cyl.setTranslateY(50);
cone.getMesh().setTranslateX(100);
cone.getMesh().setTranslateY(150);
rect.setTranslateX(-25);
rect.setTranslateY(-25);
rect.setRotationAxis(Rotate.Y_AXIS);
rect.setRotate(45);
nodes.add(box);
nodes.add(sphere);
nodes.add(cyl);
nodes.add(cone.getMesh());
nodes.add(rect);
return new Group(box, sphere, cyl, cone.getMesh(), rect);
}
示例5: makePump
import javafx.scene.shape.Cylinder; //导入方法依赖的package包/类
private Group makePump(double height, double r1, double r2, PhongMaterial headMaterial) {
double half = height / 2;
Cylinder t1 = new Cylinder(r1, height);
Cylinder t2 = new Cylinder(r2, 0.2);
Cylinder t3 = new Cylinder(r2, 0.2);
t2.setTranslateY(half);
t3.setTranslateY(-half);
t1.setMaterial(material);
t2.setMaterial(headMaterial);
t3.setMaterial(material);
return new Group(t1, t2, t3);
}
示例6: makePump1
import javafx.scene.shape.Cylinder; //导入方法依赖的package包/类
private Group makePump1(double height, double r1, double r2, PhongMaterial headMaterial) {
double half = height / 2;
Cylinder t1 = new Cylinder(r1, height);
Cylinder t2 = new Cylinder(r2, 0.2);
t2.setTranslateY(half);
t1.setMaterial(material);
t2.setMaterial(headMaterial);
return new Group(t1, t2);
}
示例7: createShape
import javafx.scene.shape.Cylinder; //导入方法依赖的package包/类
/**
* Creates a cylinder between the start and end points of the edge.
*
* @return A JavaFX Cylinder representing the given LinearEdgeComponent
*/
private Cylinder createShape(Edge edgeComponent) {
// If the edge does not have two vertices, a new shape cannot be created
if (edgeComponent.getEntitiesFromCategory(MeshCategory.VERTICES)
.size() != 2) {
return null;
}
// Get the scale the vertices are being drawn at
int scale = ((FXVertexController) edgeComponent
.getEntitiesFromCategory(MeshCategory.VERTICES).get(0))
.getApplicationScale();
// Get the edge's endpoints
double[] start = edgeComponent.getStartLocation();
double[] end = edgeComponent.getEndLocation();
for (int i = 0; i < 3; i++) {
start[i] = start[i] * scale;
end[i] = end[i] * scale;
}
// Create a cylinder situated at the edge's midpoint with the edge's
// length.
Cylinder edge = new Cylinder(.6,
Math.sqrt((Math.pow(start[0] - end[0], 2))
+ (Math.pow(start[1] - end[1], 2))
+ (Math.pow(start[2] - end[2], 2))));
edge.setTranslateX((start[0] + end[0]) / 2);
edge.setTranslateY((start[1] + end[1]) / 2);
edge.setTranslateZ((start[2] + end[2]) / 2);
// Get the angle between the two points
Point3D start3D = new Point3D(start[0], start[1], start[2]);
Point3D end3D = new Point3D(end[0], end[1], end[2]);
Point3D angle = end3D.subtract(start3D);
// Get the axis of rotation for the cylinder
Point3D axis = angle.crossProduct(0f, 1f, 0f);
// Calculate the number of degrees to rotate about the axis.
double rotationAmount = Math
.acos(angle.normalize().dotProduct(0, 1, 0));
// Apply the rotation to the cylinder
Rotate rotation = new Rotate(-Math.toDegrees(rotationAmount), axis);
edge.getTransforms().addAll(rotation);
return edge;
}
示例8: start
import javafx.scene.shape.Cylinder; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
final PhongMaterial red = new PhongMaterial(Color.RED);
final PhongMaterial green = new PhongMaterial(Color.GREEN);
final PhongMaterial blue = new PhongMaterial(Color.BLUE);
final Box cube = new Box(200, 200, 200);
cube.setLayoutX(150);
cube.setLayoutY(800);
cube.setDrawMode(DrawMode.LINE);
cube.setMaterial(red);
final Cylinder cylinder = new Cylinder(150, 50);
cylinder.setLayoutX(500);
cylinder.setLayoutY(800);
cylinder.setDrawMode(DrawMode.LINE);
cylinder.setMaterial(green);
final Sphere sphere = new Sphere(100);
sphere.setLayoutX(850);
sphere.setLayoutY(800);
sphere.setDrawMode(DrawMode.LINE);
sphere.setMaterial(blue);
final AmbientLight light = new AmbientLight(Color.WHITE);
final Pane root = new Pane();
root.setStyle("-fx-background-color: transparent;");
root.getChildren().addAll(cube, cylinder, sphere, light);
final int[] tesselations = {1, 5, 10, 50, 100};
for (int index = 0; index < tesselations.length; index++) {
final int dx = 1000 / tesselations.length;
final int tesselation = tesselations[index];
final Sphere tesselatedSphere = new Sphere(75, tesselation);
tesselatedSphere.setDrawMode(DrawMode.LINE);
root.getChildren().add(tesselatedSphere);
tesselatedSphere.setTranslateX(100 + dx * index);
tesselatedSphere.setTranslateY(400);
final Cylinder tesselatedCylinder = new Cylinder(75, 50, tesselation);
tesselatedCylinder.setDrawMode(DrawMode.LINE);
root.getChildren().add(tesselatedCylinder);
tesselatedCylinder.setTranslateX(100 + dx * index);
tesselatedCylinder.setTranslateY(100);
}
final Scene scene = new Scene(root, 1000, 1000);
scene.setFill(Color.BLACK);
scene.setCamera(new PerspectiveCamera());
primaryStage.setScene(scene);
primaryStage.setTitle("Test_Triangle");
primaryStage.show();
}