javafx.scene.shape.Box Java Examples

The following examples show how to use javafx.scene.shape.Box. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ThreeDOM.java    From scenic-view with GNU General Public License v3.0 6 votes vote down vote up
private void buildAxes(Group world) {
    PhongMaterial redMaterial = new PhongMaterial();
    redMaterial.setDiffuseColor(Color.DARKRED);
    redMaterial.setSpecularColor(Color.RED);
    PhongMaterial greenMaterial = new PhongMaterial();
    greenMaterial.setDiffuseColor(Color.DARKGREEN);
    greenMaterial.setSpecularColor(Color.GREEN);
    PhongMaterial blueMaterial = new PhongMaterial();
    blueMaterial.setDiffuseColor(Color.DARKBLUE);
    blueMaterial.setSpecularColor(Color.BLUE);

    Box xAxis = new Box(AXES_SIZE, 1, 1);
    xAxis.setMaterial(redMaterial);
    Box yAxis = new Box(1, AXES_SIZE, 1);
    yAxis.setMaterial(greenMaterial);
    Box zAxis = new Box(1, 1, AXES_SIZE);
    zAxis.setMaterial(blueMaterial);

    Group group = new Group();
    group.getChildren().addAll(xAxis, yAxis, zAxis);
    group.setVisible(true);
    world.getChildren().addAll(group);
    group.visibleProperty().bind(checkBoxAxes.selectedProperty());
}
 
Example #2
Source File: Fx3DFeatureDataset.java    From mzmine3 with GNU General Public License v2.0 5 votes vote down vote up
public Fx3DFeatureDataset(Feature feature, int rtResolution, int mzResolution,
    Range<Double> rtRange, Range<Double> mzRange, double maxOfAllBinnedIntensity,
    Color featureColor) {
  super(null, feature.toString(), featureColor);
  this.feature = feature;
  this.featureRtRange = feature.getRawDataPointsRTRange();
  this.featureMzRange = feature.getRawDataPointsMZRange();
  this.plotRtRange = rtRange;
  this.plotMzRange = mzRange;
  this.maxIntensityValue = feature.getRawDataPointsIntensityRange().upperEndpoint();

  float factorX = (float) SIZE / rtResolution;
  float factorZ = (float) SIZE / mzResolution;

  double rtSlope = SIZE / (plotRtRange.upperEndpoint() - plotRtRange.lowerEndpoint());
  double mzSlope = SIZE / (plotMzRange.upperEndpoint() - plotMzRange.lowerEndpoint());
  logger.finest("RtSlope is:" + rtSlope);
  logger.finest("MzSlope is:" + mzSlope);
  double minFeatureRtPoint =
      (featureRtRange.lowerEndpoint() - plotRtRange.lowerEndpoint()) * rtSlope;
  double maxFeatureRtPoint =
      (featureRtRange.upperEndpoint() - plotRtRange.lowerEndpoint()) * rtSlope;
  double minFeatureMzPoint =
      (featureMzRange.lowerEndpoint() - plotMzRange.lowerEndpoint()) * mzSlope;
  double maxFeatureMzPoint =
      (featureMzRange.upperEndpoint() - plotMzRange.lowerEndpoint()) * mzSlope;
  logger.finest("minRTPoint:" + minFeatureRtPoint + "  maxRTPoint:" + maxFeatureRtPoint);
  logger.finest("minMzPoint:" + minFeatureMzPoint + "  maxMzPoint:" + maxFeatureMzPoint);
  logger.finest("maxIntensityValue is:" + maxIntensityValue * AMPLIFI);
  logger.finest("maxOfAllBinnedIntensity value is:" + maxOfAllBinnedIntensity * AMPLIFI);
  double width = maxFeatureRtPoint - minFeatureRtPoint;
  double depth = maxFeatureMzPoint - minFeatureMzPoint;
  logger.finest("width is: " + width);
  logger.finest("depth is:" + depth);
  featureBox = new Box(width * factorX, maxIntensityValue * AMPLIFI, depth * factorZ);
  featureBox.setTranslateX((minFeatureRtPoint + width / 2) * factorX);
  featureBox.setTranslateY(-maxIntensityValue * AMPLIFI / 2);
  featureBox.setTranslateZ((minFeatureMzPoint + depth / 2) * factorZ);
  setNodeColor(featureColor);
}
 
Example #3
Source File: Viewer3d.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
private Xform buildAxes()
{
    Xform axes = new Xform();
    final PhongMaterial red = new PhongMaterial();
    red.setDiffuseColor(Color.RED);
    red.setSpecularColor(Color.DARKRED);

    final PhongMaterial green = new PhongMaterial();
    green.setDiffuseColor(Color.GREEN);
    green.setSpecularColor(Color.DARKGREEN);

    final PhongMaterial blue = new PhongMaterial();
    blue.setDiffuseColor(Color.BLUE);
    blue.setSpecularColor(Color.DARKBLUE);

    final Box xAxis = new Box(AXIS_LENGTH, 1, 1);
    final Box yAxis = new Box(1, AXIS_LENGTH, 1);
    final Box zAxis = new Box(1, 1, AXIS_LENGTH);

    xAxis.setTranslateX(AXIS_LENGTH/2 + 0.5);
    yAxis.setTranslateY(AXIS_LENGTH/2 + 0.5);
    zAxis.setTranslateZ(AXIS_LENGTH/2 + 0.5);

    xAxis.setMaterial(red);
    yAxis.setMaterial(green);
    zAxis.setMaterial(blue);

    axes.getChildren().addAll(xAxis, yAxis, zAxis);

    return axes;
}
 
Example #4
Source File: ContentModel.java    From gluon-samples with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
private void buildAxes() {
    double length = 2d * dimModel;
    double width = dimModel / 100d;
    double radius = 2d * dimModel / 100d;
    final PhongMaterial redMaterial = new PhongMaterial();
    redMaterial.setDiffuseColor(Color.DARKRED);
    redMaterial.setSpecularColor(Color.RED);
    final PhongMaterial greenMaterial = new PhongMaterial();
    greenMaterial.setDiffuseColor(Color.DARKGREEN);
    greenMaterial.setSpecularColor(Color.GREEN);
    final PhongMaterial blueMaterial = new PhongMaterial();
    blueMaterial.setDiffuseColor(Color.DARKBLUE);
    blueMaterial.setSpecularColor(Color.BLUE);
    
    Sphere xSphere = new Sphere(radius);
    Sphere ySphere = new Sphere(radius);
    Sphere zSphere = new Sphere(radius);
    xSphere.setMaterial(redMaterial);
    ySphere.setMaterial(greenMaterial);
    zSphere.setMaterial(blueMaterial);
    
    xSphere.setTranslateX(dimModel);
    ySphere.setTranslateY(dimModel);
    zSphere.setTranslateZ(dimModel);
    
    Box xAxis = new Box(length, width, width);
    Box yAxis = new Box(width, length, width);
    Box zAxis = new Box(width, width, length);
    xAxis.setMaterial(redMaterial);
    yAxis.setMaterial(greenMaterial);
    zAxis.setMaterial(blueMaterial);
    
    autoScalingGroup.getChildren().addAll(xAxis, yAxis, zAxis);
    autoScalingGroup.getChildren().addAll(xSphere, ySphere, zSphere);
}
 
Example #5
Source File: Histogram.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
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);
    }
}
 
Example #6
Source File: ScatterPlot.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
private Shape3D createDefaultNode(double radius) {
    switch(defaultNodeType) {
        case SPHERE: return new Sphere(radius);
        case CUBE: return new Box(radius, radius, radius);
        default: return new Box(radius, radius, radius);    
    }
}
 
Example #7
Source File: Drag3DObject.java    From FXyzLib with GNU General Public License v3.0 5 votes vote down vote up
@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);
}
 
Example #8
Source File: ContentModel.java    From RubikFX with GNU General Public License v3.0 5 votes vote down vote up
private void buildAxes() {
    double length = 2d*dimModel;
    double width = dimModel/100d;
    double radius = 2d*dimModel/100d;
    final PhongMaterial redMaterial = new PhongMaterial();
    redMaterial.setDiffuseColor(Color.DARKRED);
    redMaterial.setSpecularColor(Color.RED);
    final PhongMaterial greenMaterial = new PhongMaterial();
    greenMaterial.setDiffuseColor(Color.DARKGREEN);
    greenMaterial.setSpecularColor(Color.GREEN);
    final PhongMaterial blueMaterial = new PhongMaterial();
    blueMaterial.setDiffuseColor(Color.DARKBLUE);
    blueMaterial.setSpecularColor(Color.BLUE);
    
    Sphere xSphere = new Sphere(radius);
    Sphere ySphere = new Sphere(radius);
    Sphere zSphere = new Sphere(radius);
    xSphere.setMaterial(redMaterial);
    ySphere.setMaterial(greenMaterial);
    zSphere.setMaterial(blueMaterial);
    
    xSphere.setTranslateX(dimModel);
    ySphere.setTranslateY(dimModel);
    zSphere.setTranslateZ(dimModel);
    
    Box xAxis = new Box(length, width, width);
    Box yAxis = new Box(width, length, width);
    Box zAxis = new Box(width, width, length);
    xAxis.setMaterial(redMaterial);
    yAxis.setMaterial(greenMaterial);
    zAxis.setMaterial(blueMaterial);
    
    autoScalingGroup.getChildren().addAll(xAxis, yAxis, zAxis);
    autoScalingGroup.getChildren().addAll(xSphere, ySphere, zSphere);
}
 
Example #9
Source File: JavaFX3D.java    From JavaFX-Tutorial-Codes with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage primaryStage) {
    Box box = new Box(100, 20, 50);

    SmartGroup group = new SmartGroup();
    group.getChildren().add(box);

    Camera camera = new PerspectiveCamera();
    Scene scene = new Scene(group, WIDTH, HEIGHT);
    scene.setFill(Color.SILVER);
    scene.setCamera(camera);

    group.translateXProperty().set(WIDTH / 2);
    group.translateYProperty().set(HEIGHT / 2);
    group.translateZProperty().set(-1500);

    initMouseControl(group, scene);

    primaryStage.addEventHandler(KeyEvent.KEY_PRESSED, event -> {
        switch (event.getCode()) {
            case W:
                group.translateZProperty().set(group.getTranslateZ() + 100);
                break;
            case S:
                group.translateZProperty().set(group.getTranslateZ() - 100);
                break;
            case Q:
                group.rotateByX(10);
                break;
            case E:
                group.rotateByX(-10);
                break;
            case NUMPAD6:
                group.rotateByY(10);
                break;
            case NUMPAD4:
                group.rotateByY(-10);
                break;
        }
    });

    primaryStage.setTitle("Genuine Coder");
    primaryStage.setScene(scene);
    primaryStage.show();
}
 
Example #10
Source File: Fx3DFeatureDataset.java    From mzmine2 with GNU General Public License v2.0 4 votes vote down vote up
public Fx3DFeatureDataset(FeatureSelection featureSel, int rtResolution,
        int mzResolution, Range<Double> rtRange, Range<Double> mzRange,
        double maxOfAllBinnedIntensity, Color featureColor) {
    super(featureSel.getRawDataFile(), featureSel.getFeature().toString(),
            featureColor);
    this.featureSelection = featureSel;
    this.featureRtRange = featureSel.getFeature().getRawDataPointsRTRange();
    this.featureMzRange = featureSel.getFeature().getRawDataPointsMZRange();
    this.plotRtRange = rtRange;
    this.plotMzRange = mzRange;
    this.maxIntensityValue = featureSel.getFeature()
            .getRawDataPointsIntensityRange().upperEndpoint();

    float factorX = (float) SIZE / rtResolution;
    float factorZ = (float) SIZE / mzResolution;

    double rtSlope = (double) ((double) SIZE
            / (plotRtRange.upperEndpoint() - plotRtRange.lowerEndpoint()));
    double mzSlope = (double) ((double) SIZE
            / (plotMzRange.upperEndpoint() - plotMzRange.lowerEndpoint()));
    LOG.finest("RtSlope is:" + rtSlope);
    LOG.finest("MzSlope is:" + mzSlope);
    double minFeatureRtPoint = (double) ((featureRtRange.lowerEndpoint()
            - plotRtRange.lowerEndpoint()) * rtSlope);
    double maxFeatureRtPoint = (double) ((featureRtRange.upperEndpoint()
            - plotRtRange.lowerEndpoint()) * rtSlope);
    double minFeatureMzPoint = (double) ((featureMzRange.lowerEndpoint()
            - plotMzRange.lowerEndpoint()) * mzSlope);
    double maxFeatureMzPoint = (double) ((featureMzRange.upperEndpoint()
            - plotMzRange.lowerEndpoint()) * mzSlope);
    LOG.finest("minRTPoint:" + minFeatureRtPoint + "  maxRTPoint:"
            + maxFeatureRtPoint);
    LOG.finest("minMzPoint:" + minFeatureMzPoint + "  maxMzPoint:"
            + maxFeatureMzPoint);
    LOG.finest("maxIntensityValue is:" + maxIntensityValue * AMPLIFI);
    LOG.finest("maxOfAllBinnedIntensity value is:"
            + maxOfAllBinnedIntensity * AMPLIFI);
    double width = maxFeatureRtPoint - minFeatureRtPoint;
    double depth = maxFeatureMzPoint - minFeatureMzPoint;
    LOG.finest("width is: " + width);
    LOG.finest("depth is:" + depth);
    featureBox = new Box(width * factorX, maxIntensityValue * AMPLIFI,
            depth * factorZ);
    featureBox.setTranslateX((minFeatureRtPoint + width / 2) * factorX);
    featureBox.setTranslateY(-maxIntensityValue * AMPLIFI / 2);
    featureBox.setTranslateZ((minFeatureMzPoint + depth / 2) * factorZ);
    setNodeColor(featureColor);
}