本文整理汇总了Java中javafx.scene.shape.Box.setTranslateX方法的典型用法代码示例。如果您正苦于以下问题:Java Box.setTranslateX方法的具体用法?Java Box.setTranslateX怎么用?Java Box.setTranslateX使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类javafx.scene.shape.Box
的用法示例。
在下文中一共展示了Box.setTranslateX方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildMultipleShapes3D
import javafx.scene.shape.Box; //导入方法依赖的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: buildCubes
import javafx.scene.shape.Box; //导入方法依赖的package包/类
private void buildCubes(ActionEvent event) {
world = new XForm();
moleculeGroup = new XForm();
for (Cube cube : cubes) {
Box boxShape = new Box(cube.getSideLength(), cube.getSideLength(), cube.getSideLength());
boxShape.setMaterial(MaterialProvider.crateMaterialFromColor(Color.LIGHTSALMON));
boxShape.setTranslateX(cube.getCenter().getX());
boxShape.setTranslateY(cube.getCenter().getY());
boxShape.setTranslateZ(cube.getCenter().getZ());
// add tooltip
Tooltip tooltip = new Tooltip(cube.toString());
Tooltip.install(boxShape, tooltip);
moleculeGroup.getChildren().add(boxShape);
}
world.getChildren().add(moleculeGroup);
displayGroup.getChildren().retainAll();
displayGroup.getChildren().add(world);
}
示例3: createPlane
import javafx.scene.shape.Box; //导入方法依赖的package包/类
private void createPlane(double length) {
Box xzPlane = new Box(length, PLANE_THICKNESS, length);
xzPlane.setDrawMode(DrawMode.LINE);
xzPlane.setTranslateX(length / 2.0);
xzPlane.setTranslateZ(length / 2.0);
Box xyPlane = new Box(length, length, PLANE_THICKNESS);
xyPlane.setDrawMode(DrawMode.LINE);
xyPlane.setTranslateX(length / 2.0);
xyPlane.setTranslateY(length / 2.0);
Box yzPlane = new Box(PLANE_THICKNESS, length, length);
yzPlane.setDrawMode(DrawMode.LINE);
yzPlane.setTranslateY(length / 2.0);
yzPlane.setTranslateZ(length / 2.0);
this.group.getChildren().addAll(xzPlane, xyPlane, yzPlane);
}
示例4: buildGroup
import javafx.scene.shape.Box; //导入方法依赖的package包/类
private static Group buildGroup() {
Group grp = new Group();
Sphere s = new Sphere();
Box b = new Box();
s.setScaleX(SCALE);
s.setScaleY(SCALE);
s.setScaleZ(SCALE);
s.setTranslateX(-130);
b.setScaleX(SCALE);
b.setScaleY(SCALE);
b.setScaleZ(SCALE);
b.setTranslateX(130);
PhongMaterial material = new PhongMaterial();
material.setDiffuseColor(Color.LIGHTGRAY);
material.setSpecularColor(Color.rgb(30, 30, 30));
s.setMaterial(material);
b.setMaterial(material);
PointLight pl = new PointLight(Color.AQUA);
pl.setTranslateZ(-1000);
Sphere lightBalance = new Sphere();
// lightBalance.setScaleX(0.1);
// lightBalance.setScaleX(0.1);
// lightBalance.setScaleX(0.1);
lightBalance.setTranslateZ(1000);
grp.getChildren().addAll(s, b,pl,lightBalance);
return grp;
}
示例5: buildMultipleShapes
import javafx.scene.shape.Box; //导入方法依赖的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);
}
示例6: createAxis
import javafx.scene.shape.Box; //导入方法依赖的package包/类
private void createAxis(double length) {
Box x = new Box(length, AXIS_THICKNESS, AXIS_THICKNESS);
x.setMaterial(new PhongMaterial(Color.BLUE));
x.setTranslateX(length / 2.0);
Box y = new Box(AXIS_THICKNESS, length, AXIS_THICKNESS);
y.setMaterial(new PhongMaterial(Color.RED));
y.setTranslateY(length / 2.0);
Box z = new Box(AXIS_THICKNESS, AXIS_THICKNESS, length);
z.setMaterial(new PhongMaterial(Color.GREEN));
z.setTranslateZ(length / 2.0);
this.group.getChildren().addAll(x, y, z);
}
示例7: AxesGrid
import javafx.scene.shape.Box; //导入方法依赖的package包/类
/**
* Construct a new axes and grid in 3D.
*
* @param length length of the axis and grid
*/
public AxesGrid(double length) {
redMaterial.setDiffuseColor(Color.RED);
redMaterial.setSpecularColor(Color.PINK);
greenMaterial.setDiffuseColor(Color.GREEN);
greenMaterial.setSpecularColor(Color.LIGHTGREEN);
blueMaterial.setDiffuseColor(Color.BLUE);
blueMaterial.setSpecularColor(Color.LIGHTBLUE);
blackMaterial.setDiffuseColor(Color.BLACK);
blackMaterial.setSpecularColor(Color.BLACK);
final Box xAxis = new Box(length, AXES_THICKNESS, AXES_THICKNESS);
xAxis.setTranslateX(length / 2.0);
xAxis.setMaterial(redMaterial);
final Box yAxis = new Box(AXES_THICKNESS, length, AXES_THICKNESS);
yAxis.setTranslateY(length / 2.0);
yAxis.setMaterial(greenMaterial);
final Box zAxis = new Box(AXES_THICKNESS, AXES_THICKNESS, length);
zAxis.setTranslateZ(length / 2.0);
zAxis.setMaterial(blueMaterial);
this.getChildren().addAll(xAxis, yAxis, zAxis);
for (int i = (int) -length; i <= length; i++) {
addXLine(length * 2, i);
}
for (int i = (int) -length; i <= length; i++) {
addYLine(length * 2, i);
}
}
示例8: TransformGizmo
import javafx.scene.shape.Box; //导入方法依赖的package包/类
/**
*
* @param axisSize
*/
public TransformGizmo(double axisSize) {
super();
if (axisSize > 0) {
this.axisSize = axisSize;
axisXMaterial = new PhongMaterial();
axisXMaterial.setDiffuseColor(Color.RED);
axisYMaterial = new PhongMaterial();
axisYMaterial.setDiffuseColor(Color.GREEN);
axisZMaterial = new PhongMaterial();
axisZMaterial.setDiffuseColor(Color.BLUE);
PhongMaterial handleMaterial = new PhongMaterial();
handleMaterial.setDiffuseColor(Color.BLUE);
setDepthTest(DepthTest.DISABLE);
createAxes(axisSize, axisWidth);
handleX = new Box(15, 15, 15);
handleX.setDepthTest(DepthTest.DISABLE);
handleX.setMaterial(handleMaterial);
handleX.setTranslateX(axisSize);
handleX.setTranslateY(0);
handleX.setTranslateZ(0);
handleY = new Box(15, 15, 15);
handleY.setDepthTest(DepthTest.DISABLE);
handleY.setMaterial(handleMaterial);
handleY.setTranslateX(0);
handleY.setTranslateY(-axisSize);
handleY.setTranslateZ(0);
handleZ = new Box(15, 15, 15);
handleZ.setDepthTest(DepthTest.DISABLE);
handleZ.setMaterial(handleMaterial);
handleZ.setTranslateX(0);
handleZ.setTranslateY(0);
handleZ.setTranslateZ(axisSize);
ObservableList<Node> children = getChildren();
children.add(handleX);
children.add(handleY);
children.add(handleZ);
//The gizmo will initially be drawn on a 1 to 1 scale
currentSize = 1;
}
}
示例9: addYLine
import javafx.scene.shape.Box; //导入方法依赖的package包/类
/**
* Add to the Group a narrow box that resembles a line in y-direction of the
* given total length centered on the z-axis and offset by the given xOffset.
*
* @param length total length
* @param xOffset position on the x-axis
*/
private void addYLine(double length, double xOffset) {
Box yLine = new Box(GRID_THICKNESS, length, GRID_THICKNESS);
yLine.setMaterial(blackMaterial);
yLine.setTranslateX(xOffset);
this.getChildren().add(yLine);
}