本文整理汇总了Java中javafx.scene.shape.Cylinder类的典型用法代码示例。如果您正苦于以下问题:Java Cylinder类的具体用法?Java Cylinder怎么用?Java Cylinder使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Cylinder类属于javafx.scene.shape包,在下文中一共展示了Cylinder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initKeys
import javafx.scene.shape.Cylinder; //导入依赖的package包/类
@Override
protected void initKeys(Scene scene) {
scene.addEventHandler(KeyEvent.ANY, new EventHandler<KeyEvent>() {
@Override
public void handle(KeyEvent t) {
switch (t.getText()) {
case "1":
setShape(Shape.Sphere);
break;
case "2":
setShape(Shape.Box);
break;
case "3":
setShape(Shape.Cylinder);
break;
}
}
});
}
示例2: 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());
}
示例3: 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;
}
示例4: 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);
}
示例5: servoHeadMale
import javafx.scene.shape.Cylinder; //导入依赖的package包/类
public CSG servoHeadMale(double headHeight, double headDiameter, int toothCount, double toothHeight,
double toothWidth, double toothLength) {
double clear = 0.3;
double radius = headDiameter / 2 - toothHeight + clear;
CSG cylinder = new eu.mihosoft.vrl.v3d.Cylinder(new Vector3d(0, 0, 0), new Vector3d(0, 0, headHeight),
radius + 0.03, toothCount * 2).toCSG();
CSG t = Extrude.points(new Vector3d(0, 0, headHeight), new Vector3d(-toothLength / 2, 0),
new Vector3d(-toothWidth / 2, toothHeight), new Vector3d(toothWidth / 2, toothHeight),
new Vector3d(toothLength / 2, 0));
double delta = 360.0 / toothCount;
CSG result = makeTooth(radius, 0, t);
for (int i = 1; i < toothCount; i++) {
CSG tooth = makeTooth(radius, i * delta, t);
result = result.union(tooth);
}
return result.union(cylinder);
}
示例6: Bone
import javafx.scene.shape.Cylinder; //导入依赖的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.shape.Cylinder; //导入依赖的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: getShapes
import javafx.scene.shape.Cylinder; //导入依赖的package包/类
@Override
protected Shape3D[] getShapes() {
Shape3D[] result = {
new Cylinder(1.3, 2),
new Cylinder(1.3, 2)
};
result[1].setTranslateX(2);
result[0].setTranslateX(-1);
return result;
}
示例9: getShapes
import javafx.scene.shape.Cylinder; //导入依赖的package包/类
@Override
protected Shape3D[] getShapes() {
Shape3D[] result = {
new Box(2, 2, 2),
new Cylinder(1, 4)
};
result[0].setTranslateX(1);
result[0].setRotationAxis(Rotate.Y_AXIS);
result[0].setRotate(45);
result[1].setRotationAxis(Rotate.X_AXIS);
result[1].setRotate(45);
return result;
}
示例10: initTestCase
import javafx.scene.shape.Cylinder; //导入依赖的package包/类
public void initTestCase(TestCaseType type) {
if (isThereTestCase) {
root.getChildren().clear();
nodes.clear();
lights.clear();
movers.clear();
}
switch (type) {
case SINGLE_SPHERE_CASE:
root.getChildren().add(buildSingle(new Sphere(50)));
break;
case SINGLE_BOX_CASE:
root.getChildren().add(buildSingle(new Box(100, 100, 100)));
break;
case SINGLE_CYLINDER_CASE:
root.getChildren().add(buildSingle(new Cylinder(50, 100)));
break;
case SINGLE_MESH_CASE:
Cone cone = new Cone(50, 100);
root.getChildren().add(buildSingle(cone.getMesh()));
break;
case MULTIPLE_SHAPE3D_CASE:
root.getChildren().add(buildMultipleShapes3D());
break;
case MULTIPLE_SHAPE_CASE:
root.getChildren().add(buildMultipleShapes());
break;
}
isThereTestCase = true;
}
示例11: 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);
}
示例12: createDefaultNode
import javafx.scene.shape.Cylinder; //导入依赖的package包/类
private Node createDefaultNode(double barWidth, double barHeight) {
switch (defaultNodeType) {
case CYLINDER:
return new Cylinder(barWidth / 2, barHeight);
case CUBE:
return new Box(barWidth, barHeight, barWidth);
default:
return new Box(barWidth, barHeight, barWidth);
}
}
示例13: Axes
import javafx.scene.shape.Cylinder; //导入依赖的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));
}
示例14: testGetCylinderAdjuster
import javafx.scene.shape.Cylinder; //导入依赖的package包/类
@Test
public void testGetCylinderAdjuster() {
Adjuster adjuster = Adjuster.getAdjuster(Cylinder.class);
assertThat(adjuster, is(instanceOf(NodeAdjuster.class)));
assertThat(adjuster.getNodeClass(), is(sameInstance(Node.class)));
}
示例15: 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);
}