Java 类javafx.scene.transform.Translate 实例源码

项目:javaone2016    文件:BadgePresenter.java   
private List<Point2D> maxScale(List<Point2D> points, double factor) {
    List<Point2D> scaledList = new ArrayList<>();
    if (!drawPath.getElements().isEmpty()) {
        // scale and center
        Bounds b0 = drawPath.getBoundsInParent();
        if (b0.getWidth() > 0 && b0.getHeight() > 0) {
            final double w = drawPane.getWidth() - 2 * factor * MARGIN; 
            final double h = drawPane.getHeight() - 2 * factor * MARGIN;
            final double scale = Math.min(w / b0.getWidth(), h / b0.getHeight());
            affine = new Affine(new Scale(scale, scale, factor * MARGIN, factor * MARGIN));
            affine.append(new Translate(factor * MARGIN - b0.getMinX() + (w - scale * b0.getWidth()) / 2d / scale, 
                              factor * MARGIN - b0.getMinY() + (h - scale * b0.getHeight()) / 2d / scale));

            for (Point2D p : points) {
                scaledList.add(affine.transform(p));
            }
        }
    }
    return scaledList;
}
项目:openjfx-8u-dev-tests    文件:Scene3D.java   
public Scene3D(Parent parent, double width, double height) {
//    super(new Group(parent), width, height, true);  // see http://javafx-jira.kenai.com/browse/RT-22696
    super(new Group(parent), width, height);


     if (true == Platform.isSupported(ConditionalFeature.SCENE3D)) {
         setCamera(new PerspectiveCamera());

         Translate centerTranslate = new Translate();
         centerTranslate.xProperty().bind(widthProperty().divide(2));
         centerTranslate.yProperty().bind(heightProperty().divide(2));

         getRoot().getTransforms().addAll(centerTranslate, translateZ, rotateX, rotateY, translateY);
       //  getRoot().setDepthTest(DepthTest.ENABLE);// see http://javafx-jira.kenai.com/browse/RT-22696
     }

 }
项目:j.commons    文件:RadialMenuSkinBase.java   
private void bindCoords() {
    final DoubleExpression radius = model.sizeProperty().multiply(0.5);
    final Translate translation = new Translate();
    translation.xProperty().bind(transformRadius);

    final Rotate rotation = new Rotate();
    rotation.pivotXProperty().bind(transformRadius.subtract(radius).multiply(-1));
    rotation.pivotYProperty().bind(radius);
    rotation.angleProperty().bind(transformAngle);

    button.getTransforms().addAll(translation, rotation);

    final Rotate twist = new Rotate();
    twist.pivotXProperty().bind(radius);
    twist.pivotYProperty().bind(radius);
    twist.angleProperty().bind(transformAngle.multiply(-1.0d));

    button.getTransforms().add(twist);

    model.visibleProperty().addListener((observable) -> {
        updateVisibility();
    });
}
项目:Consume    文件:PlayerHUD.java   
public void setBossBar(Entity boss) {
    getChildren().remove(bossHealthBar);

    bossHealthBar = new ValueBar(95, 20, boss.<Enemy>getProperty(Property.DATA).curHealth, boss.<Enemy>getProperty(Property.DATA).maxHealth, Color.YELLOW);
    bossHealthBar.getTransforms().add(new Rotate(270));
    bossHealthBar.getTransforms().add(new Translate(-10, 580, 0));
    boss.<Enemy>getProperty(Property.DATA).curHealth.addListener(new ChangeListener<Number>() {
        @Override
        public void changed(ObservableValue<? extends Number> arg0, Number arg1, Number arg2) {
            if (arg2.intValue() <= 0) {
                FadeTransition ft = new FadeTransition(Duration.seconds(1), bossHealthBar);
                ft.setFromValue(1);
                ft.setToValue(0);
                ft.setOnFinished((event) -> bossHealthBar.setVisible(false));
                ft.play();
            }
        }
    });
    getChildren().add(bossHealthBar);
}
项目:FX3DAndroid    文件:ScadaApplication.java   
private void makePedestal(ObservableList<Node> g) {
    // pedestal
    Box box = new Box(5.5, 0.2, 5);
    box.setMaterial(material2);
    // box.setTranslateY(3);

    double length1 = 4.2;
    // outlet dispatch tube
    Capsule t1 = new Capsule(0.3, length1);
    t1.setCullFace(CullFace.BACK);
    t1.setMaterial(material);
    t1.getTransforms().addAll(new Rotate(90, X_AXIS), new Translate(0, -length1 / 2, -0.4));

    double length2 = 4.4;
    // outlet endpoint supply tube
    Group tg = makePump(length2, 0.3, 0.35, material);
    tg.getTransforms().addAll(new Rotate(90, X_AXIS), new Translate(-2.8, 0, -1.5));

    g.addAll(t1, tg, box);

    // TriangleMesh mesh = createToroidMesh(2f, 0.5f, 100, 100);
    // g.addAll(new MeshView(mesh));
}
项目:RiggedHand    文件:Bone.java   
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));
}
项目:RiggedHand    文件:Axes.java   
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));
}
项目:narjillos    文件:EggView.java   
public Node toNode(double zoomLevel, boolean infraredOn, boolean effectsOn) {
    if (zoomLevel < MINIMUM_ZOOM_LEVEL)
        return null;

    waveAngle = Angle.normalize(waveAngle + BLOBBING_SPEED);
    shape.setRadiusX(Math.min(getEgg().getAge(), Configuration.EGG_RADIUS + RADIUS_VARIATION * FastMath.sin(waveAngle)));
    shape.setRadiusY(Math.min(getEgg().getAge(), Configuration.EGG_RADIUS + RADIUS_VARIATION * FastMath.cos(waveAngle)));

    shape.setFill(getFillColor(infraredOn));

    if (effectsOn)
        shape.setEffect(getEffects(zoomLevel, infraredOn));

    shape.getTransforms().clear();
    Translate translation = new Translate(getThing().getPosition().x, getThing().getPosition().y);
    shape.getTransforms().add(translation);

    return shape;
}
项目:narjillos    文件:EyesView.java   
public EyesView(Narjillo narjillo) {
    this.narjillo = narjillo;

    Fiber fiber = narjillo.getBody().getHead().getFiber();
    this.eyeRed = fiber.getPercentOfRed();
    this.eyeGreen = fiber.getPercentOfGreen();
    this.eyeBlue = fiber.getPercentOfBlue();

    // "Random qualities": we want something that looks random across narjillos,
    // but stays the same for the same narjillo even after saving and reloading
    double someRandomQuality = narjillo.getBody().getAdultMass();
    double someOtherRandomQuality = narjillo.getBody().getEnergyToChildren();

    this.eye1 = new Circle(someRandomQuality % 5 + 7);
    this.eye2 = new Circle(someOtherRandomQuality % 5 + 7);
    this.pupil1 = new Circle(Math.min(eye1.getRadius() - 2, someRandomQuality % 6 + 1));
    this.pupil2 = new Circle(Math.min(eye1.getRadius() - 2, someOtherRandomQuality % 6 + 1));

    eyeCenteringTranslation = eye1.getRadius() - eye2.getRadius();
    pupilTranslation = Math.min(eye2.getRadius() - pupil2.getRadius(), eye1.getRadius() - pupil1.getRadius());

    this.eye1.getTransforms().add(new Translate(eyeCenteringTranslation - eye1.getRadius() + 1, 0));
    this.eye2.getTransforms().add(new Translate(eyeCenteringTranslation + eye2.getRadius() - 1, 0));
}
项目:narjillos    文件:OrganView.java   
private Shape getShape(double zoomLevel, boolean effectsOn) {

        segment.setWidth(organ.getLength() + getOverlap() * 2);
        segment.setHeight(organ.getThickness());

        segment.getTransforms().clear();
        // overlap slightly and shift to center based on thickness
        double widthCenter = organ.getThickness() / 2;
        segment.getTransforms().add(moveToStartPoint());
        segment.getTransforms().add(new Translate(-getOverlap(), -widthCenter));
        segment.getTransforms().add(new Rotate(organ.getAbsoluteAngle(), getOverlap(), widthCenter));

        boolean isHighDetail = hasJoint && zoomLevel >= VERY_HIGH_MAGNIFICATION && effectsOn;

        if (!isHighDetail)
            return segment;

        joint.setRadius(getJointRadius(organ.getThickness()));

        joint.getTransforms().clear();
        joint.getTransforms().add(moveToStartPoint());
        joint.getTransforms().add(new Translate(organ.getLength(), 0));
        joint.getTransforms().add(new Rotate(organ.getAbsoluteAngle(), -organ.getLength(), 0));

        return Path.union(segment, joint);
    }
项目:narjillos    文件:MouthView.java   
@Override
public Node toNode(double zoomLevel, boolean infraredOn, boolean effectsOn) {
    if (zoomLevel < MINIMUM_ZOOM_LEVEL)
        return null;

    Color color = getColor(zoomLevel, infraredOn);
    for (int i = 0; i < lines.length; i++) {
        lines[i].setStroke(color);
        rotateLine(i);
    }

    Vector position = getNarjillo().getPosition();
    group.getTransforms().clear();
    group.getTransforms().add(new Translate(position.x, position.y));

    return group;
}
项目:incubator-netbeans    文件:Cube3D.java   
private void init(Stage primaryStage) {
    Group root = new Group();
    root.setDepthTest(DepthTest.ENABLE);
    primaryStage.setResizable(false);
    primaryStage.setScene(new Scene(root, 400, 150, true));
    primaryStage.getScene().setCamera(new PerspectiveCamera());
    root.getTransforms().addAll(
        new Translate(400 / 2, 150 / 2),
        new Rotate(180, Rotate.X_AXIS)
    );
    root.getChildren().add(create3dContent());
}
项目:incubator-netbeans    文件:CubeSystem3D.java   
private void init(Stage primaryStage) {
    Group root = new Group();
    root.setDepthTest(DepthTest.ENABLE);
    primaryStage.setResizable(false);
    primaryStage.setScene(new Scene(root, 500, 500, true));
    primaryStage.getScene().setCamera(new PerspectiveCamera());
    root.getTransforms().addAll(
        new Translate(500 / 2, 500 / 2),
        new Rotate(180, Rotate.X_AXIS)
    );
    root.getChildren().add(create3dContent());
}
项目:incubator-netbeans    文件:AudioVisualizer3D.java   
private void init(Stage primaryStage) {
    Group root = new Group();
    root.setDepthTest(DepthTest.ENABLE);
    primaryStage.setResizable(false);
    primaryStage.setScene(new Scene(root, 400, 500, true));
    primaryStage.getScene().setCamera(new PerspectiveCamera());
    root.getTransforms().addAll(
        new Translate(400 / 2, 500 / 2 + 100),
        new Rotate(180, Rotate.X_AXIS)
    );
    root.getChildren().add(create3dContent());
}
项目:marathonv5    文件:Sample3D.java   
protected Sample3D(double width, double height) {
    super(width, height);
    Group group3d = new Group(create3dContent());
    group3d.setDepthTest(DepthTest.ENABLE);
    group3d.getTransforms().addAll(
            new Translate(width / 2, height / 2),
            new Rotate(180, Rotate.X_AXIS)
    );
    getChildren().add(group3d);
}
项目:marathonv5    文件:Sample3D.java   
protected Sample3D(double width, double height) {
    super(width, height);
    Group group3d = new Group(create3dContent());
    group3d.setDepthTest(DepthTest.ENABLE);
    group3d.getTransforms().addAll(
            new Translate(width / 2, height / 2),
            new Rotate(180, Rotate.X_AXIS)
    );
    getChildren().add(group3d);
}
项目:DUTS3-CPOA-ProjetTarot    文件:Transformations.java   
/**
 * Constructs a Transformation with a node
 * @since v0.4
 *
 * @param object the node we add transformation getters
 * @see Node
 */
public Transformations(Node object)
{
    double pivotX = object.getBoundsInLocal().getWidth()/2;
    double pivotY = object.getBoundsInLocal().getHeight()/2;
    double pivotZ = object.getBoundsInLocal().getDepth()/2;
    rotateX = new Rotate(0, pivotX, pivotY, pivotZ, Rotate.X_AXIS);
    rotateY = new Rotate(0, pivotX, pivotY, pivotZ, Rotate.Y_AXIS);
    rotateZ = new Rotate(0, pivotX, pivotY, pivotZ, Rotate.Z_AXIS);
    incline = new Rotate(0, pivotX, object.getBoundsInLocal().getDepth(), pivotZ, Rotate.Y_AXIS);
    translate = new Translate(0,0,0);
    object.getTransforms().addAll(translate, incline, rotateX, rotateY, rotateZ); //The order of adding the transformations is important !
}
项目:j.commons    文件:RadialMenuItem.java   
private Text generateCaret(RadialMenuParams params) {
    final FontAwesomeIcon icon = FontAwesomeIcon.CARET_RIGHT;
    final Text result = GlyphsDude.createIcon(icon, "1em");
    result.setY(radius);
    result.setTextOrigin(VPos.CENTER);

    final Translate caretTranslation = new Translate();
    caretTranslation.setX(button.getPrefHeight() + params.outerPaddingProperty().get() * 0.5);
    result.getTransforms().add(caretTranslation);
    return result;
}
项目:eavp    文件:Util.java   
/**
 * <p>
 * Converts an ICE Geometry Transformation data structure to a JavaFX
 * Transform.
 * </p>
 * 
 * @param transform
 *            ICE Transformation data structure
 * @return a JavaFX transformation that is analagous to the Transformation
 */
public static Transform convertTransformation(
        Transformation transformation) {
    Affine transform = new Affine();

    if (transformation == null) {
        return transform;
    }

    double size = transformation.getSize();
    double[] scale = transformation.getScale();
    double[] rotation = transformation.getRotation();
    double[] translation = transformation.getTranslation();

    Scale sizeXform = new Scale(size, size, size);
    Scale scaleXform = new Scale(scale[0], scale[1], scale[2]);
    Rotate rotateXform = eulerToRotate(rotation[0], rotation[1],
            rotation[2]);
    Translate translateXform = new Translate(translation[0], translation[1],
            translation[2]);
    Transform transformOutput = transform
            .createConcatenation(translateXform)
            .createConcatenation(rotateXform).createConcatenation(sizeXform)
            .createConcatenation(scaleXform);

    return transformOutput;
}
项目:jfx.radialmenu    文件:RadialMenuItem.java   
private Text generateCaret(RadialMenuParams params) {
    final FontAwesomeIcon icon = FontAwesomeIcon.CARET_RIGHT;
    final Text result = GlyphsDude.createIcon(icon, "1em");
    result.setY(radius);
    result.setTextOrigin(VPos.CENTER);

    final Translate caretTranslation = new Translate();
    caretTranslation.setX(button.getPrefHeight() + params.outerPaddingProperty().get() * 0.5);
    result.getTransforms().add(caretTranslation);
    return result;
}
项目:JFoenix    文件:SVGGlyphLoader.java   
/**
 * will retrieve icons from the glyphs map for a certain glyphName
 *
 * @param glyphName the glyph name
 * @return SVGGlyph node
 */
public static SVGGlyph getIcoMoonGlyph(String glyphName) throws Exception{
    SVGGlyphBuilder builder = glyphsMap.get(glyphName);
    if(builder == null) throw new Exception("Glyph '" + glyphName + "' not found!");
    SVGGlyph glyph = builder.build();
    // we need to apply transformation to correct the icon since
    // its being inverted after importing from icomoon
    glyph.getTransforms().add(new Scale(1, -1));
    Translate height = new Translate();
    height.yProperty().bind(Bindings.createDoubleBinding(() -> -glyph.getHeight(), glyph.heightProperty()));
    glyph.getTransforms().add(height);
    return glyph;
}
项目:dnainator    文件:AbstractView.java   
/**
 * Constructs a new {@link AbstractView}. Sets up the necessary transforms and
 * translations for the panning and zooming.
 */
public AbstractView() {
    loadFXML();
    getStyleClass().add("view");
    toCenter = new Translate();
    widthProperty().addListener((o, v1, v2) -> toCenter.setX(v2.intValue() / 2));
    heightProperty().addListener((o, v1, v2) -> toCenter.setY(v2.intValue() / 2));

    translate = new Translate();
    scale = getScale();
}
项目:clarity-analyzer    文件:MainPresenter.java   
private void resizeMapControl() {
    double scale = Math.min(mapCanvasPane.getWidth() / mapControl.getSize(), mapCanvasPane.getHeight() / mapControl.getSize());

    double sw = mapControl.getSize() * scale;
    double dx = mapCanvasPane.getWidth() - sw;
    double dy = mapCanvasPane.getHeight() - sw;

    mapCanvasPane.getTransforms().clear();
    mapCanvasPane.getTransforms().add(new Scale(scale, scale));
    mapCanvasPane.getTransforms().add(new Translate(0.5 * dx / scale, 0.5 * dy / scale));
}
项目:fr.xs.jtk    文件:Planetoid.java   
public void animate() {
    selfRotation().play();
    Timeline t = new Timeline(new KeyFrame(Duration.millis(20), e -> {
        a = a + 0.0002f;

        Translate translate = new Translate(Math.cos(a) * (bean.getApoastre() / 2), 0, Math.sin(a) * (bean.getPeriastre() / 2));
        getTransforms().addAll(translate);
    }));
    t.setCycleCount(Timeline.INDEFINITE);
    t.play();

}
项目:fr.xs.jtk    文件:Axes.java   
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));
}
项目:fr.xs.jtk    文件:ABunchOfMeshTest.java   
protected static Group aBunchOfCapsules() {
    Group capsuleGroup = new Group();
    for(int i = 0; i < 50; i++) {
        Random r = new Random();
        float randomRadius = (float) ((r.nextFloat() * 100) + 25);
        float randomHeight = (float) ((r.nextFloat() * 300) + 75);
        Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());

        Capsule cap = new Capsule(randomRadius, randomHeight, randomColor);
        cap.setEmissiveLightingColor(randomColor);
        cap.setEmissiveLightingOn(r.nextBoolean());
        cap.setDrawMode(r.nextBoolean() ? DrawMode.FILL : DrawMode.LINE);

        double translationX = Math.random() * 1024 * 1.95;
        if(Math.random() >= 0.5) {
            translationX *= -1;
        }
        double translationY = Math.random() * 1024 * 1.95;
        if(Math.random() >= 0.5) {
            translationY *= -1;
        }
        double translationZ = Math.random() * 1024 * 1.95;
        if(Math.random() >= 0.5) {
            translationZ *= -1;
        }
        Translate translate = new Translate(translationX, translationY, translationZ);
        Rotate rotateX = new Rotate(Math.random() * 360, Rotate.X_AXIS);
        Rotate rotateY = new Rotate(Math.random() * 360, Rotate.Y_AXIS);
        Rotate rotateZ = new Rotate(Math.random() * 360, Rotate.Z_AXIS);

        cap.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);

        capsuleGroup.getChildren().add(cap);
    }

    return capsuleGroup;
}
项目:fr.xs.jtk    文件:ABunchOfMeshTest.java   
protected static Group aBunchOfCones() {
       Group coneGroup = new Group();        
       for (int i = 0; i < 100; i++) {
           Random r = new Random();
           //A lot of magic numbers in here that just artificially constrain the math
           float randomRadius = (float) ((r.nextFloat()*100) + 25);
           float randomHeight = (float) ((r.nextFloat()*300)+ 75);
           int randomDivisions = (int) ((r.nextFloat()*50) + 5);
           Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());

           Cone cone = new Cone(randomDivisions, randomRadius, randomHeight, randomColor);               
           cone.setEmissiveLightingColor(randomColor);
           cone.setEmissiveLightingOn(r.nextBoolean());
           cone.setDrawMode(r.nextBoolean() ? DrawMode.FILL : DrawMode.LINE);

           double translationX = Math.random() * 1024;
           if (Math.random() >= 0.5) {
               translationX *= -1;
           }
           double translationY = Math.random() * 1024;
           if (Math.random() >= 0.5) {
               translationY *= -1;
           }
           double translationZ = Math.random() * 1024;
           if (Math.random() >= 0.5) {
               translationZ *= -1;
           }
           Translate translate = new Translate(translationX, translationY, translationZ);
           Rotate rotateX = new Rotate(Math.random() * 360, Rotate.X_AXIS);
           Rotate rotateY = new Rotate(Math.random() * 360, Rotate.Y_AXIS);
           Rotate rotateZ = new Rotate(Math.random() * 360, Rotate.Z_AXIS);

           cone.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);

           coneGroup.getChildren().add(cone);
       }

    return coneGroup;
}
项目:fr.xs.jtk    文件:ABunchOfMeshTest.java   
protected static Group aBunchOfSpheroid() {

        Group spheroidGroup = new Group();
        for(int i = 0; i < 50; i++) {
            Random r = new Random();
            // A lot of magic numbers in here that just artificially constrain
            // the math
            float randomMajorRadius = (float) ((r.nextFloat() * 300) + 50);
            float randomMinorRadius = (float) ((r.nextFloat() * 300) + 50);
            int randomDivisions = (int) ((r.nextFloat() * 64) + 1);
            Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());

            Spheroid sm = new Spheroid(randomDivisions, randomMajorRadius, randomMinorRadius, randomColor);
            sm.setDrawMode(DrawMode.LINE);
            double translationX = Math.random() * 1024 * 1.95;
            if(Math.random() >= 0.5) {
                translationX *= -1;
            }
            double translationY = Math.random() * 1024 * 1.95;
            if(Math.random() >= 0.5) {
                translationY *= -1;
            }
            double translationZ = Math.random() * 1024 * 1.95;
            if(Math.random() >= 0.5) {
                translationZ *= -1;
            }
            Translate translate = new Translate(translationX, translationY, translationZ);
            Rotate rotateX = new Rotate(Math.random() * 360, Rotate.X_AXIS);
            Rotate rotateY = new Rotate(Math.random() * 360, Rotate.Y_AXIS);
            Rotate rotateZ = new Rotate(Math.random() * 360, Rotate.Z_AXIS);

            sm.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);

            spheroidGroup.getChildren().add(sm);
        }

        return spheroidGroup;
    }
项目:fr.xs.jtk    文件:ABunchOfMeshTest.java   
protected static Group aBunchOfOctahedron() {
    Group octahedronGroup = new Group();
    for(int i = 0; i < 100; i++) {
        Random r = new Random();
        // A lot of magic numbers in here that just artificially constrain
        // the math
        float randomHypotenuse = (float) ((r.nextFloat() * 300) + 25);
        float randomHeight = (float) ((r.nextFloat() * 200) + 25);
        Color randomColor = new Color(r.nextDouble(), r.nextDouble(), r.nextDouble(), r.nextDouble());

        Octahedron octahedron = new Octahedron(randomHypotenuse, randomHeight, randomColor);
        octahedron.setEmissiveLightingColor(randomColor);
        octahedron.setEmissiveLightingOn(r.nextBoolean());
        octahedron.setDrawMode(r.nextBoolean() ? DrawMode.FILL : DrawMode.LINE);

        double translationX = Math.random() * 1024;
        if(Math.random() >= 0.5) {
            translationX *= -1;
        }
        double translationY = Math.random() * 1024;
        if(Math.random() >= 0.5) {
            translationY *= -1;
        }
        double translationZ = Math.random() * 1024;
        if(Math.random() >= 0.5) {
            translationZ *= -1;
        }
        Translate translate = new Translate(translationX, translationY, translationZ);
        Rotate rotateX = new Rotate(Math.random() * 360, Rotate.X_AXIS);
        Rotate rotateY = new Rotate(Math.random() * 360, Rotate.Y_AXIS);
        Rotate rotateZ = new Rotate(Math.random() * 360, Rotate.Z_AXIS);

        octahedron.getTransforms().addAll(translate, rotateX, rotateY, rotateZ);

        octahedronGroup.getChildren().add(octahedron);
    }

    return octahedronGroup;
}
项目:FXyzLib    文件:Axes.java   
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));
}
项目:org.csstudio.display.builder    文件:ProgressBarRepresentation.java   
@Override
public void updateChanges()
{
    super.updateChanges();
    if (dirty_look.checkAndClear())
    {
        boolean horizontal = model_widget.propHorizontal().getValue();
        double width = model_widget.propWidth().getValue();
        double height = model_widget.propHeight().getValue();
        if (!horizontal)
        {
            jfx_node.setPrefSize(height, width);
            jfx_node.getTransforms().setAll(
                    new Translate(0, height),
                    new Rotate(-90, 0, 0));
        }
        else
        {
            jfx_node.setPrefSize(width, height);
            jfx_node.getTransforms().clear();
        }
        // Could clear style and use setBackground(),
        // but result is very plain.
        // Tweaking the color used by CSS keeps overall style.
        // See also http://stackoverflow.com/questions/13467259/javafx-how-to-change-progressbar-color-dynamically
        jfx_node.setStyle("-fx-accent: " + JFXUtil.webRGB(model_widget.propFillColor().getValue()));
    }
    if (dirty_value.checkAndClear())
        jfx_node.setProgress(percentage);
}
项目:Connect4-Java    文件:Window.java   
public Window() {
    // make a new Ellipse and Translate, add the Translate to the Ellipse, add the Ellipse to the Group 
    pos = new Translate();
    e = new Ellipse();
    e.setFill(Color.WHITE);
    getChildren().addAll(e);
    e.getTransforms().add(pos);
    e.setFill(Color.WHITE);
}
项目:FX3DAndroid    文件:Axes.java   
public Axes(double scale) {
    axisX.getTransforms().addAll(new Rotate(90, Rotate.Z_AXIS), new Translate(0, 30, 0));
    axisX.setMaterial(new PhongMaterial(Color.RED));
    axisY.getTransforms().add(new Translate(0, 30, 0));
    axisY.setMaterial(new PhongMaterial(Color.GREEN));
    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));
}
项目:FX3DAndroid    文件:Axes.java   
public void setHeight(double equalHeights) {
    double oldHeight = axisX.getHeight();
    axisX.setHeight(equalHeights);
    axisX.getTransforms().add(new Translate(0, (equalHeights/2.0)-(oldHeight/2.0), 0));
    axisY.setHeight(equalHeights);
    axisY.getTransforms().add(new Translate(0, (equalHeights/2.0)-(oldHeight/2.0), 0));
    axisZ.setHeight(equalHeights);
    axisZ.getTransforms().add(new Translate(0,(equalHeights/2.0)-(oldHeight/2.0), 0));
}
项目:javafx-demos    文件:JavaFX_Transform.java   
@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("java-buddy.blogspot.com");
    Group root = new Group();
    Scene scene = new Scene(root, 300, 250);

    Rectangle rect1 = new Rectangle(100, 100, Color.BLUE);  //without translate
    Rectangle rect2 = new Rectangle(100, 100, Color.RED);   //with translate
    rect2.getTransforms().add(new Translate(150, 50));          //Translate(double x, double y)

    root.getChildren().add(rect1);
    root.getChildren().add(rect2);
    primaryStage.setScene(scene);
    primaryStage.show();
}
项目:narjillos    文件:EnvironmentView.java   
private Group getThingsGroup(boolean infraredOn, boolean effectsOn) {
    Group things = new Group();
    things.getChildren().addAll(getNodesForThingsInOrder(infraredOn, effectsOn));

    if (VisualDebugger.DEBUG)
        things.getChildren().add(getVisualDebuggingSegments());

    things.getTransforms().add(new Translate(-viewport.getPositionEC().x, -viewport.getPositionEC().y));
    things.getTransforms().add(
        new Scale(viewport.getZoomLevel(), viewport.getZoomLevel(), viewport.getPositionEC().x, viewport.getPositionEC().y));

    return things;
}
项目:narjillos    文件:SpecklesView.java   
public Node toNode(boolean infraredOn) {
    Node result = infraredOn ? infraredBackground : background;

    double minimumZoomLevelToSeeSpeckles = 0.20;
    if (viewport.getZoomLevel() <= minimumZoomLevelToSeeSpeckles)
        return null;

    result.getTransforms().clear();
    result.getTransforms().add(new Translate(-viewport.getPositionEC().x, -viewport.getPositionEC().y));
    result.getTransforms().add(
            new Scale(viewport.getZoomLevel(), viewport.getZoomLevel(), viewport.getPositionEC().x, viewport.getPositionEC().y));

    return result;
}
项目:SettlersJava    文件:GameGroup.java   
public void addTiles() {
    for (Tile tile : Board.getTiles()) {
        MeshView mesh = tile.getMesh();
        PhongMaterial material = new PhongMaterial(Color.WHITE);
        material.setDiffuseMap(new Image(GameGroup.class.getResourceAsStream(tile.getResourceString())));
        mesh.setMaterial(material);
        mesh.getTransforms().add(new Translate(tile.getCenter().getX(), tile.getCenter().getY(), tile.getCenter().getZ()));
        getChildren().add(mesh);
    }
}
项目:kotlinfx-ensemble    文件:Sample3D.java   
protected Sample3D(double width, double height) {
    super(width, height);
    Group group3d = new Group(create3dContent());
    group3d.setDepthTest(DepthTest.ENABLE);
    group3d.getTransforms().addAll(
            new Translate(width / 2, height / 2),
            new Rotate(180, Rotate.X_AXIS)
    );
    getChildren().add(group3d);
}
项目:DUTS3-CPOA-ProjetTarot    文件:Transformations.java   
public Translate getTranslate()
{
    return translate;
}