Example #1
0
  public void remove(int k) {
    try {
      zAxisData.remove(k);
      xAxisData.remove(k);
      yAxisData.remove(k);
    } catch (Exception e) {
      e.printStackTrace();
    }

    Platform.runLater(
        () -> {
          scatterDataGroup.getChildren().clear();
          for (int i = 0; i < zAxisData.size(); i++) {
            final Sphere dataSphere = new Sphere(scatterRadius);
            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);
          }
        });
  }
Example #2
0
  private void init(LedColor initialColor) {
    PhongMaterial material = new PhongMaterial();
    material.setDiffuseColor(initialColor.getColor());

    int ledSpacing = 60;
    int ledSize = 10;

    for (int x = 0; x < cubeSize; x++) {
      for (int y = 0; y < cubeSize; y++) {
        for (int z = 0; z < cubeSize; z++) {
          final Sphere led = new Sphere(ledSize);
          led.setMaterial(material);
          led.setTranslateX(x * (ledSize + ledSpacing) + ledSize);
          led.setTranslateY(y * (ledSize + ledSpacing) + ledSize);
          led.setTranslateZ(z * (ledSize + ledSpacing) + ledSize);
          led.setOnMouseClicked(
              event -> {
                fireOnClick(event);
              });
          led.setUserData(new Coordinate3D(x, z, cubeSize - y - 1));
          getChildren().add(led);
          leds.add(led);
        }
      }
    }

    // add some axis
    Bounds b = getBoundsInLocal();

    Cylinder xAxis = new Cylinder(2, b.getMaxX());
    xAxis.setMaterial(new PhongMaterial(Color.RED));
    xAxis.getTransforms().add(new Rotate(90, Rotate.Z_AXIS));
    xAxis.setTranslateX(b.getMaxX() / 2);
    xAxis.setTranslateY(b.getMaxY() + 20);
    getChildren().add(xAxis);

    Cylinder yAxis = new Cylinder(2, b.getMaxZ());
    yAxis.setMaterial(new PhongMaterial(Color.BLUE));
    yAxis.getTransforms().add(new Rotate(90, Rotate.X_AXIS));
    yAxis.setTranslateX(-20);
    yAxis.setTranslateY(b.getMaxY() + 20);
    yAxis.setTranslateZ(b.getMaxZ() / 2);
    getChildren().add(yAxis);

    Cylinder zAxis = new Cylinder(2, b.getMaxX());
    zAxis.setMaterial(new PhongMaterial(Color.GREEN));
    zAxis.setTranslateX(-20);
    zAxis.setTranslateY(b.getMaxY() / 2);
    getChildren().add(zAxis);
  }
Example #3
0
 /** @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);
   }
 }
  public View23D() {
    this.setAlignment(Pos.CENTER);
    this.setPadding(new Insets(20));

    camera = new PerspectiveCamera();
    camera.setNearClip(0.1);
    camera.setFarClip(10000);
    camera.setTranslateX(0);
    camera.setTranslateY(0);
    camera.setTranslateZ(-500);

    sphere1 = createSphere(Color.BLUE);
    Tooltip.install(sphere1, new Tooltip("A Blue Sphere"));

    sphere2 = createSphere(Color.YELLOWGREEN);
    sphere2.setTranslateX(200);
    sphere2.setTranslateY(200);
    Tooltip.install(sphere2, new Tooltip("A Yellowgreen Sphere"));

    cylinder = createCylinder(Color.BLANCHEDALMOND);
    cylinder.setTranslateY(90);
    cylinder.setTranslateX(90);
    cylinder.setRotate(-45);
    Tooltip.install(cylinder, new Tooltip("A ??? Cylinder"));

    clickMe1 = new Button("Click Me!");
    clickMe1.setTranslateX(200);

    t3dobjects = new Group();

    t3dobjects.getChildren().addAll(sphere1, cylinder, sphere2, clickMe1);

    threeD = new SubScene(t3dobjects, 600, 600, true, SceneAntialiasing.BALANCED);
    t3dobjects.setTranslateX(200);
    t3dobjects.setTranslateY(200);

    topPane = new Pane();
    topPane.setPickOnBounds(false);

    clickMe2 = new Button("Click Me 2!");

    this.getChildren().addAll(threeD, topPane);
    // this.setAlignment(Pos.CENTER);
  }
Example #5
0
  public void addData(double x, double y, double z) {
    zAxisData.add(z);
    xAxisData.add(x);
    yAxisData.add(y);
    Platform.runLater(
        () -> {
          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);
          }
        });
  }
Example #6
0
  private void buildAxes(double size, double axisThickness) {
    // X-Axis Material
    final PhongMaterial redMaterial = new PhongMaterial();
    redMaterial.setDiffuseColor(Color.DARKRED);
    redMaterial.setSpecularColor(Color.RED);
    // Y-Axis Material
    final PhongMaterial greenMaterial = new PhongMaterial();
    greenMaterial.setDiffuseColor(Color.DARKGREEN);
    greenMaterial.setSpecularColor(Color.GREEN);
    // Z-Axis Material
    final PhongMaterial blueMaterial = new PhongMaterial();
    blueMaterial.setDiffuseColor(Color.DARKBLUE);
    blueMaterial.setSpecularColor(Color.BLUE);

    // XYZ 1
    final Cylinder x1AxisCyl = new Cylinder(axisThickness, size);
    final Cylinder y1AxisCyl = new Cylinder(axisThickness, size);
    final Cylinder z1AxisCyl = new Cylinder(axisThickness, size);
    x1AxisCyl.setTranslateY(size / 2);
    x1AxisCyl.setTranslateZ(-size / 2);

    y1AxisCyl.setTranslateX(-size / 2);
    y1AxisCyl.setTranslateZ(-size / 2);

    z1AxisCyl.setTranslateX((-size) / 2);
    z1AxisCyl.setTranslateY(size / 2);

    x1AxisCyl.setRotationAxis(Rotate.Z_AXIS);
    x1AxisCyl.setRotate(90);
    z1AxisCyl.setRotationAxis(Rotate.X_AXIS);
    z1AxisCyl.setRotate(-90);

    x1AxisCyl.setMaterial(redMaterial);
    y1AxisCyl.setMaterial(greenMaterial);
    z1AxisCyl.setMaterial(blueMaterial);

    // getChildren().addAll(x1AxisCyl, y1AxisCyl, z1AxisCyl);
    // XYZ 2
    final Cylinder x2AxisCyl = new Cylinder(axisThickness, size);
    final Cylinder y2AxisCyl = new Cylinder(axisThickness, size);
    final Cylinder z2AxisCyl = new Cylinder(axisThickness, size);

    x2AxisCyl.setTranslateY(size / 2);
    x2AxisCyl.setTranslateZ(size / 2);

    y2AxisCyl.setTranslateX(size / 2);
    y2AxisCyl.setTranslateZ(size / 2);

    z2AxisCyl.setTranslateX(size / 2);
    z2AxisCyl.setTranslateY(size / 2);

    x2AxisCyl.setRotationAxis(Rotate.Z_AXIS);
    x2AxisCyl.setRotate(90);
    z2AxisCyl.setRotationAxis(Rotate.X_AXIS);
    z2AxisCyl.setRotate(-90);

    x2AxisCyl.setMaterial(redMaterial);
    y2AxisCyl.setMaterial(greenMaterial);
    z2AxisCyl.setMaterial(blueMaterial);

    // getChildren().addAll(x2AxisCyl, y2AxisCyl, z2AxisCyl);
    // XYZ 3
    final Cylinder x3AxisCyl = new Cylinder(axisThickness, size);
    final Cylinder y3AxisCyl = new Cylinder(axisThickness, size);
    final Cylinder z3AxisCyl = new Cylinder(axisThickness, size);

    x3AxisCyl.setTranslateY(-size / 2);
    x3AxisCyl.setTranslateZ(-size / 2);

    y3AxisCyl.setTranslateX(size / 2);
    y3AxisCyl.setTranslateZ(-size / 2);

    z3AxisCyl.setTranslateX(size / 2);
    z3AxisCyl.setTranslateY(-size / 2);

    x3AxisCyl.setRotationAxis(Rotate.Z_AXIS);
    x3AxisCyl.setRotate(90);
    z3AxisCyl.setRotationAxis(Rotate.X_AXIS);
    z3AxisCyl.setRotate(-90);

    x3AxisCyl.setMaterial(redMaterial);
    y3AxisCyl.setMaterial(greenMaterial);
    z3AxisCyl.setMaterial(blueMaterial);

    // getChildren().addAll(x3AxisCyl, y3AxisCyl, z3AxisCyl);
    // XYZ 4
    final Cylinder x4AxisCyl = new Cylinder(axisThickness, size);
    final Cylinder y4AxisCyl = new Cylinder(axisThickness, size);
    final Cylinder z4AxisCyl = new Cylinder(axisThickness, size);

    x4AxisCyl.setTranslateY(-size / 2);
    x4AxisCyl.setTranslateZ(size / 2);

    y4AxisCyl.setTranslateX(-size / 2);
    y4AxisCyl.setTranslateZ(size / 2);

    z4AxisCyl.setTranslateX(-size / 2);
    z4AxisCyl.setTranslateY(-size / 2);

    x4AxisCyl.setRotationAxis(Rotate.Z_AXIS);
    x4AxisCyl.setRotate(90);
    z4AxisCyl.setRotationAxis(Rotate.X_AXIS);
    z4AxisCyl.setRotate(-90);

    x4AxisCyl.setMaterial(redMaterial);
    y4AxisCyl.setMaterial(greenMaterial);
    z4AxisCyl.setMaterial(blueMaterial);

    // getChildren().addAll(x4AxisCyl, y4AxisCyl, z4AxisCyl);
    xAxesGroup.getChildren().addAll(x1AxisCyl, x2AxisCyl, x3AxisCyl, x4AxisCyl);
    yAxesGroup.getChildren().addAll(y1AxisCyl, y2AxisCyl, y3AxisCyl, y4AxisCyl);
    zAxesGroup.getChildren().addAll(z1AxisCyl, z2AxisCyl, z3AxisCyl, z4AxisCyl);

    getChildren().addAll(xAxesGroup, yAxesGroup, zAxesGroup);

    // f**k it throw a little sphere at the corners
    final Sphere top1Sphere = new Sphere(2 * axisThickness);
    final Sphere top2Sphere = new Sphere(2 * axisThickness);
    final Sphere top3Sphere = new Sphere(2 * axisThickness);
    final Sphere top4Sphere = new Sphere(2 * axisThickness);
    final Sphere bottom1Sphere = new Sphere(2 * axisThickness);
    final Sphere bottom2Sphere = new Sphere(2 * axisThickness);
    final Sphere bottom3Sphere = new Sphere(2 * axisThickness);
    final Sphere bottom4Sphere = new Sphere(2 * axisThickness);
    top1Sphere.setTranslateX(-size / 2);
    top1Sphere.setTranslateY(-size / 2);
    top1Sphere.setTranslateZ(-size / 2);
    top2Sphere.setTranslateX(-size / 2);
    top2Sphere.setTranslateY(-size / 2);
    top2Sphere.setTranslateZ(size / 2);
    top3Sphere.setTranslateX(size / 2);
    top3Sphere.setTranslateY(-size / 2);
    top3Sphere.setTranslateZ(size / 2);
    top4Sphere.setTranslateX(size / 2);
    top4Sphere.setTranslateY(-size / 2);
    top4Sphere.setTranslateZ(-size / 2);
    bottom1Sphere.setTranslateX(-size / 2);
    bottom1Sphere.setTranslateY(size / 2);
    bottom1Sphere.setTranslateZ(-size / 2);
    bottom2Sphere.setTranslateX(-size / 2);
    bottom2Sphere.setTranslateY(size / 2);
    bottom2Sphere.setTranslateZ(size / 2);
    bottom3Sphere.setTranslateX(size / 2);
    bottom3Sphere.setTranslateY(size / 2);
    bottom3Sphere.setTranslateZ(size / 2);
    bottom4Sphere.setTranslateX(size / 2);
    bottom4Sphere.setTranslateY(size / 2);
    bottom4Sphere.setTranslateZ(-size / 2);
    sphereGroup
        .getChildren()
        .addAll(
            top1Sphere,
            top2Sphere,
            top3Sphere,
            top4Sphere,
            bottom1Sphere,
            bottom2Sphere,
            bottom3Sphere,
            bottom4Sphere);
    getChildren().add(sphereGroup);
  }