本文整理汇总了Java中javafx.scene.shape.Cylinder.setTranslateX方法的典型用法代码示例。如果您正苦于以下问题:Java Cylinder.setTranslateX方法的具体用法?Java Cylinder.setTranslateX怎么用?Java Cylinder.setTranslateX使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.shape.Cylinder
的用法示例。
在下文中一共展示了Cylinder.setTranslateX方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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);
}
示例4: 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;
}
示例5: 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();
}
示例6: buildMolecule
import javafx.scene.shape.Cylinder; //导入方法依赖的package包/类
private void buildMolecule() {
final PhongMaterial redMaterial = new PhongMaterial();
redMaterial.setDiffuseColor(Color.DARKRED);
redMaterial.setSpecularColor(Color.RED);
final PhongMaterial whiteMaterial = new PhongMaterial();
whiteMaterial.setDiffuseColor(Color.WHITE);
whiteMaterial.setSpecularColor(Color.LIGHTBLUE);
final PhongMaterial greyMaterial = new PhongMaterial();
greyMaterial.setDiffuseColor(Color.DARKGREY);
greyMaterial.setSpecularColor(Color.GREY);
// Molecule Hierarchy
// [*] moleculeXform
// [*] oxygenXform
// [*] oxygenSphere
// [*] hydrogen1SideXform
// [*] hydrogen1Xform
// [*] hydrogen1Sphere
// [*] bond1Cylinder
// [*] hydrogen2SideXform
// [*] hydrogen2Xform
// [*] hydrogen2Sphere
// [*] bond2Cylinder
Xform moleculeXform = new Xform();
Xform oxygenXform = new Xform();
Xform hydrogen1SideXform = new Xform();
Xform hydrogen1Xform = new Xform();
Xform hydrogen2SideXform = new Xform();
Xform hydrogen2Xform = new Xform();
Sphere oxygenSphere = new Sphere(40.0);
oxygenSphere.setMaterial(redMaterial);
Sphere hydrogen1Sphere = new Sphere(30.0);
hydrogen1Sphere.setMaterial(whiteMaterial);
hydrogen1Sphere.setTranslateX(0.0);
Sphere hydrogen2Sphere = new Sphere(30.0);
hydrogen2Sphere.setMaterial(whiteMaterial);
hydrogen2Sphere.setTranslateZ(0.0);
Cylinder bond1Cylinder = new Cylinder(5, 100);
bond1Cylinder.setMaterial(greyMaterial);
bond1Cylinder.setTranslateX(50.0);
bond1Cylinder.setRotationAxis(Rotate.Z_AXIS);
bond1Cylinder.setRotate(90.0);
Cylinder bond2Cylinder = new Cylinder(5, 100);
bond2Cylinder.setMaterial(greyMaterial);
bond2Cylinder.setTranslateX(50.0);
bond2Cylinder.setRotationAxis(Rotate.Z_AXIS);
bond2Cylinder.setRotate(90.0);
moleculeXform.getChildren().add(oxygenXform);
moleculeXform.getChildren().add(hydrogen1SideXform);
moleculeXform.getChildren().add(hydrogen2SideXform);
oxygenXform.getChildren().add(oxygenSphere);
hydrogen1SideXform.getChildren().add(hydrogen1Xform);
hydrogen2SideXform.getChildren().add(hydrogen2Xform);
hydrogen1Xform.getChildren().add(hydrogen1Sphere);
hydrogen2Xform.getChildren().add(hydrogen2Sphere);
hydrogen1SideXform.getChildren().add(bond1Cylinder);
hydrogen2SideXform.getChildren().add(bond2Cylinder);
hydrogen1Xform.setTx(100.0);
hydrogen2Xform.setTx(100.0);
hydrogen2SideXform.setRotateY(104.5);
moleculeGroup.getChildren().add(moleculeXform);
world.getChildren().addAll(moleculeGroup);
}