本文整理汇总了Java中javafx.scene.shape.Cylinder.setMaterial方法的典型用法代码示例。如果您正苦于以下问题:Java Cylinder.setMaterial方法的具体用法?Java Cylinder.setMaterial怎么用?Java Cylinder.setMaterial使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.shape.Cylinder
的用法示例。
在下文中一共展示了Cylinder.setMaterial方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: 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);
}
示例2: 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));
}
示例3: 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));
}
示例4: 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));
}
示例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: addLeafBond
import javafx.scene.shape.Cylinder; //导入方法依赖的package包/类
private void addLeafBond(LeafSubstructure origin, OakBond bond) {
Cylinder bondShape = createCylinderConnecting(bond.getSource().getPosition(), bond.getTarget().getPosition());
bondShape.setMaterial(getMaterial(origin, bond));
moleculeGroup.getChildren().add(bondShape);
}
示例8: addChainBond
import javafx.scene.shape.Cylinder; //导入方法依赖的package包/类
private void addChainBond(Chain origin, OakBond bond) {
Cylinder bondShape = createCylinderConnecting(bond.getSource().getPosition(), bond.getTarget().getPosition());
bondShape.setMaterial(getMaterial(origin, bond));
moleculeGroup.getChildren().add(bondShape);
}
示例9: 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();
}
示例10: 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);
}
示例11: start
import javafx.scene.shape.Cylinder; //导入方法依赖的package包/类
@Override
public void start(Stage primaryStage) throws Exception {
primaryStage.setResizable(false);
Scene scene = new Scene(root, 1024, 800, true);
// Create and position camera
Camera camera = new PerspectiveCamera();
camera.getTransforms().addAll(
new Rotate(0, Rotate.Y_AXIS),
new Rotate(0, Rotate.X_AXIS),
new Translate(-500, -425, 1200));
scene.setCamera(camera);
scene.setFill(Paint.valueOf(Color.BLACK.toString()));
// Box
testObject = new Cylinder(10, 50);
testObject.setMaterial(new PhongMaterial(Color.RED));
testObject.getTransforms().addAll(new Translate(50, 0, 0));
TdsModelImporter model_importer = new TdsModelImporter();
model_importer.read(getClass().getResource("/models/SpaceLaunchSystem.3DS"));
Node[] nodes = model_importer.getImport();
model_importer.close();
Group rocket = new Group(nodes);
rocket.getTransforms().addAll(new Translate(0, 25, 0));
// Build the Scene Graph
root.getChildren().addAll(testObject, rocket);
primaryStage.setScene(scene);
primaryStage.show();
primaryStage.setOnCloseRequest(new EventHandler<WindowEvent>() {
@Override
public void handle(WindowEvent event) {
System.out.println(event);
if (event.getEventType().equals(WindowEvent.WINDOW_CLOSE_REQUEST)) {
System.exit(0);
}
}
});
mqttClient.subscribe(MQTT_TOPIC_IMU + "/#");
}