本文整理汇总了Java中javafx.scene.shape.Sphere类的典型用法代码示例。如果您正苦于以下问题:Java Sphere类的具体用法?Java Sphere怎么用?Java Sphere使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Sphere类属于javafx.scene.shape包,在下文中一共展示了Sphere类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: initKeys
import javafx.scene.shape.Sphere; //导入依赖的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: buildGroup
import javafx.scene.shape.Sphere; //导入依赖的package包/类
private static Group buildGroup() {
Sphere s = new Sphere();
s.setScaleX(SCALE);
s.setScaleY(SCALE);
s.setScaleZ(SCALE);
PhongMaterial material = new PhongMaterial();
material.setDiffuseColor(Color.LIGHTGRAY);
material.setSpecularColor(Color.rgb(30, 30, 30));
s.setMaterial(material);
// PointLight pl = new PointLight(Color.AQUA);
// pl.setTranslateZ(-1000);
Group group = new Group(/*pl,*/ s);
group.setTranslateX(SS_WIDTH / 2);
group.setTranslateY(SS_HEIGHT / 2);
return group;
}
示例3: buildMultipleShapes3D
import javafx.scene.shape.Sphere; //导入依赖的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());
}
示例4: initScene
import javafx.scene.shape.Sphere; //导入依赖的package包/类
@Override
protected void initScene() {
DefaultMeshBuilder dmb = new DefaultMeshBuilder() {
@Override
protected double function(double fx, double fy) {
return 1;
}
};
MeshView meshView = new MeshView(dmb.getTriangleMesh());
meshView.setScaleX(100);
meshView.setScaleY(100);
meshView.setScaleZ(100);
Sphere s = new Sphere(50);
s.setTranslateX(WIDTH / 2);
s.setTranslateY(HEIGHT / 2);
Group root = new Group(s, meshView);
scene = createScene(root, WIDTH, HEIGHT);
scene.setCamera(new PerspectiveCamera());
}
示例5: setxAxisData
import javafx.scene.shape.Sphere; //导入依赖的package包/类
/**
* @param data the xAxisData to set
*/
public void setxAxisData(ArrayList<Double> data) {
xAxisData = data;
scatterDataGroup.getChildren().clear();
for(int i=0;i<xAxisData.size();i++) {
final Sphere dataSphere = new Sphere(scatterRadius);
// final Box dataSphere = new Box(getScatterRadius(), getScatterRadius(), getScatterRadius());
double translateY = 0.0;
double translateZ = 0.0;
if(!yAxisData.isEmpty() && yAxisData.size() > i)
translateY = yAxisData.get(i);
if(!zAxisData.isEmpty() && zAxisData.size() > i)
translateZ = zAxisData.get(i);
dataSphere.setTranslateX(xAxisData.get(i));
dataSphere.setTranslateY(translateY);
dataSphere.setTranslateZ(translateZ);
scatterDataGroup.getChildren().add(dataSphere);
}
}
示例6: setyAxisData
import javafx.scene.shape.Sphere; //导入依赖的package包/类
/**
* @param data the yAxisData to set
*/
public void setyAxisData(ArrayList<Double> data) {
yAxisData = data;
scatterDataGroup.getChildren().clear();
for(int i=0;i<yAxisData.size();i++) {
final Sphere dataSphere = new Sphere(scatterRadius);
// final Box dataSphere = new Box(getScatterRadius(), getScatterRadius(), getScatterRadius());
double translateX = 0.0;
double translateZ = 0.0;
if(!xAxisData.isEmpty() && xAxisData.size() > i)
translateX = xAxisData.get(i);
if(!zAxisData.isEmpty() && zAxisData.size() > i)
translateZ = zAxisData.get(i);
dataSphere.setTranslateX(translateX);
dataSphere.setTranslateY(yAxisData.get(i));
dataSphere.setTranslateZ(translateZ);
scatterDataGroup.getChildren().add(dataSphere);
}
}
示例7: setzAxisData
import javafx.scene.shape.Sphere; //导入依赖的package包/类
/**
* @param data the zAxisData to set
*/
public void setzAxisData(ArrayList<Double> data) {
zAxisData = data;
scatterDataGroup.getChildren().clear();
for(int i=0;i<zAxisData.size();i++) {
final Sphere dataSphere = new Sphere(scatterRadius);
// final Box dataSphere = new Box(getScatterRadius(), getScatterRadius(), getScatterRadius());
double translateX = 0.0;
double translateY = 0.0;
if(!xAxisData.isEmpty() && xAxisData.size() > i)
translateX = xAxisData.get(i);
if(!yAxisData.isEmpty() && yAxisData.size() > i)
translateY = yAxisData.get(i);
dataSphere.setTranslateX(translateX);
dataSphere.setTranslateY(translateY);
dataSphere.setTranslateZ(zAxisData.get(i));
scatterDataGroup.getChildren().add(dataSphere);
}
}
示例8: drawLocus
import javafx.scene.shape.Sphere; //导入依赖的package包/类
private void drawLocus(Physical ball) {
// Main スレッド以外で UI を操作するとエラーになるので、 Platform.runLater() を使って UI スレッドで処理を実行する
Platform.runLater(() -> {
Sphere sphere = this.createSphere(ball);
Deque<Sphere> spheres = this.spheresMap.computeIfAbsent(ball, (key) -> new ArrayDeque<>());
spheres.addLast(sphere);
this.group.getChildren().add(sphere);
if (this.historySzie < spheres.size()) {
Sphere removed = spheres.removeFirst();
this.group.getChildren().remove(removed);
}
});
}
示例9: Bone
import javafx.scene.shape.Sphere; //导入依赖的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));
}
示例10: start
import javafx.scene.shape.Sphere; //导入依赖的package包/类
@Override
public void start(Stage stage) {
Box floor = new Box(1000, 10, 1000);
floor.setTranslateY(150);
root.getChildren().add(floor);
Sphere s = new Sphere(150);
s.setTranslateX(5);
s.setPickOnBounds(true);
root.getChildren().add(s);
showStage(stage);
}
示例11: buildGroup
import javafx.scene.shape.Sphere; //导入依赖的package包/类
@Override
protected Group buildGroup() {
material = new PhongMaterial();
material.setDiffuseColor(Color.LIGHTGRAY);
material.setSpecularColor(Color.rgb(30, 30, 30));
grp = new Group();
setShape(Shape.Sphere);
return grp;
}
示例12: buildGroup
import javafx.scene.shape.Sphere; //导入依赖的package包/类
public Group buildGroup() {
initMaterials();
meshView = new Shape3D[(int) Math.pow(side, 3) - (int) Math.pow(side - 2, 3)];
int i = 0;
for (int x = 0; x < side; x++) {
for (int y = 0; y < side; y++) {
for (int z = 0; z < side; z++) {
if (x == 0 || y == 0 || z == 0 || z == side - 1 || y == side - 1 || x == side - 1) {
meshView[i] = new Sphere(radius);
meshView[i].setMaterial(getMtrl(x, y, z));
meshView[i].setScaleX(SCALE);
meshView[i].setScaleY(SCALE);
meshView[i].setScaleZ(SCALE);
meshView[i].setTranslateX((x - (side) / 2) * SCALE * 2 * radius + SCALE * radius);
meshView[i].setTranslateY((y - (side) / 2) * SCALE * 2 * radius + SCALE * radius);
meshView[i].setTranslateZ((z - (side) / 2) * SCALE * 2 * radius + SCALE * radius);
i++;
}
}
}
}
root = new Group(meshView);
root.setFocusTraversable(true);
grp = new Group(root);
return grp;
}
示例13: buildGroup
import javafx.scene.shape.Sphere; //导入依赖的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;
}
示例14: buildGroup
import javafx.scene.shape.Sphere; //导入依赖的package包/类
private SubScene buildGroup(int num) {
Sphere s = new Sphere(50);
nodes[num] = s;
Group grp = new Group(s);
grp.setTranslateX(SS_WIDTH / 2);
grp.setTranslateY(SS_HEIGHT / 2);
roots[num] = grp;
SubScene ss = createSubScene(grp, SS_WIDTH, SS_HEIGHT);
ss.setCamera(new PerspectiveCamera());
return ss;
}
示例15: getShapes
import javafx.scene.shape.Sphere; //导入依赖的package包/类
@Override
protected Shape3D[] getShapes() {
Shape3D[] result = {
new Sphere(1),
new Sphere(1),
};
result[1].setTranslateX(1);
result[0].setTranslateX(-1);
return result;
}