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

项目:Recordian    文件:GraphsTabController.java   
/**
 * Converts charts to Java {@link WritableImage}s
 *
 * @param charts the charts to be converted to {@link WritableImage}s
 * @return a {@link List} of {@link WritableImage}s
 */
private List<WritableImage> chartsToImages(List<Chart> charts) {
    List<WritableImage> chartImages = new ArrayList<>();

    // Scaling the chart image gives it a higher resolution
    // which results in a better image quality when the
    // image is exported to the pdf
    SnapshotParameters snapshotParameters = new SnapshotParameters();
    snapshotParameters.setTransform(new Scale(2, 2));

    for (Chart chart : charts) {
        chartImages.add(chart.snapshot(snapshotParameters, null));
    }

    return  chartImages;
}
项目:incubator-netbeans    文件:DigitalClock.java   
@Override
public void start(Stage primaryStage) {
    primaryStage.setTitle("Digital Clock");
    Group root = new Group();
    Scene scene = new Scene(root, 480, 412);
    // add background image
    ImageView background = new ImageView(new Image(getClass().getResourceAsStream("DigitalClock-background.png")));
    // add digital clock
    clock = new Clock(Color.ORANGERED, Color.rgb(50,50,50));
    clock.setLayoutX(45);
    clock.setLayoutY(186);
    clock.getTransforms().add(new Scale(0.83f, 0.83f, 0, 0));
    // add background and clock to sample
    root.getChildren().addAll(background, clock);
    primaryStage.setScene(scene);
    primaryStage.show();
}
项目: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;
}
项目:ColorSelector    文件:ColorSelector.java   
private void resize() {
    double width  = getWidth() - getInsets().getLeft() - getInsets().getRight();
    double height = getHeight() - getInsets().getTop() - getInsets().getBottom();
    size   = width < height ? width : height;

    if (width > 0 && height > 0) {
        pane.setMaxSize(size, size);
        pane.relocate((getWidth() - size) * 0.5, (getHeight() - size) * 0.5);

        double center = size * 0.5;
        scaleFactor = size / PREFERRED_WIDTH;
        ring.getTransforms().setAll(new Scale(scaleFactor, scaleFactor, 0, 0));

        mainCircle.setRadius(size * 0.21016949);
        mainCircle.setCenterX(center); mainCircle.setCenterY(center);
    }
}
项目:FXGL    文件:GameScene.java   
private void initViewport(double w, double h) {
    Viewport viewport = getViewport();
    gameRoot.layoutXProperty().bind(viewport.xProperty().negate());
    gameRoot.layoutYProperty().bind(viewport.yProperty().negate());

    Scale scale = new Scale();
    scale.pivotXProperty().bind(viewport.xProperty());
    scale.pivotYProperty().bind(viewport.yProperty());
    scale.xProperty().bind(viewport.zoomProperty());
    scale.yProperty().bind(viewport.zoomProperty());
    gameRoot.getTransforms().add(scale);

    Rotate rotate = new Rotate(0, Rotate.Z_AXIS);
    rotate.pivotXProperty().bind(viewport.xProperty().add(w / 2));
    rotate.pivotYProperty().bind(viewport.yProperty().add(h / 2));
    rotate.angleProperty().bind(viewport.angleProperty().negate());
    gameRoot.getTransforms().add(rotate);
}
项目:FlagMaker-2    文件:OverlayTransformer.java   
private Transform GetTransformation(int width, int height)
{
    double centerX = width * GetDoubleAttribute("X") / MaximumX;
    double centerY = height * GetDoubleAttribute("Y") / MaximumY;

    double skewX = 90 * (GetDoubleAttribute("SkewX") - MaximumX / 2.0) / MaximumX;
    double skewY = 90 * (GetDoubleAttribute("SkewY") - MaximumY / 2.0) / MaximumY;

    double scaleX = GetDoubleAttribute("Width");
    double scaleY = GetDoubleAttribute("Height");

    double rotation = (GetDoubleAttribute("Rotation") / MaximumX) * 360;

    Shear skewTransform = new Shear(skewX, skewY, centerX, centerY);
    Rotate rotateTransform = new Rotate(rotation, centerX, centerY);
    Scale scaleTransform = new Scale(scaleX, scaleY, centerX, centerY);

    return rotateTransform.createConcatenation(scaleTransform).createConcatenation(skewTransform);
}
项目:org.csstudio.display.builder    文件:JFXRepresentation.java   
/** Update lines that indicate model's size in edit mode */
private void updateModelSizeIndicators()
{
    int width = model.propWidth().getValue();
    int height = model.propHeight().getValue();

    final ObservableList<Transform> transforms = widget_parent.getTransforms();
    if (transforms.size() > 0  &&  transforms.get(0) instanceof Scale)
    {
        final Scale scale = (Scale) transforms.get(0);
        width  *= scale.getX();
        height *= scale.getY();
    }

    horiz_bound.setStartY(height);
    horiz_bound.setEndX(width);
    horiz_bound.setEndY(height);

    vert_bound.setStartX(width);
    vert_bound.setEndY(height);
    vert_bound.setEndX(width);
}
项目:org.csstudio.display.builder    文件:EmbeddedDisplayRepresentation.java   
@Override
public ScrollPane createJFXNode() throws Exception
{
    // inner.setScaleX() and setScaleY() zoom from the center
    // and not the top-left edge, requiring adjustments to
    // inner.setTranslateX() and ..Y() to compensate.
    // Using a separate Scale transformation does not have that problem.
    // See http://stackoverflow.com/questions/10707880/javafx-scale-and-translate-operation-results-in-anomaly
    inner = new Pane();
    inner.getTransforms().add(zoom = new Scale());

    scroll = new ScrollPane(inner);
    // Panning tends to 'jerk' the content when clicked
    // scroll.setPannable(true);

    if (!toolkit.isEditMode())
    {   // Hide border around the ScrollPane
        // Details changed w/ JFX versions, see
        // http://stackoverflow.com/questions/17540137/javafx-scrollpane-border-and-background/17540428#17540428
        scroll.setStyle("-fx-background-color:transparent;");
    }

    return scroll;
}
项目:archivo    文件:TaskProgressIndicatorSkin.java   
@Override
protected void layoutChildren() {
    // calculate scale
    double scale = getWidth() / computePrefWidth(-1);
    getChildren().stream().filter(child -> child instanceof Region).forEach(child -> {
        Region region = (Region) child;
        if (region.getShape() != null) {
            region.resize(
                    region.getShape().getLayoutBounds().getMaxX(),
                    region.getShape().getLayoutBounds().getMaxY()
            );
            region.getTransforms().setAll(new Scale(scale, scale, 0, 0));
        } else {
            region.autosize();
        }
    });
}
项目: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));
}
项目:MetroProgressIndicator    文件:MetroProgressIndicatorSkin.java   
@Override
protected void layoutChildren()
{
    // calculate scale
    double scale = this.getWidth() / this.computePrefWidth(-1);
    for (Node child : this.getChildren())
    {
        if (child instanceof Region)
        {
            Region region = (Region) child;
            if (region.getShape() != null)
            {
                region.resize(region.getShape().getLayoutBounds().getMaxX(), region
                        .getShape().getLayoutBounds().getMaxY());
                region.getTransforms().setAll(new Scale(scale, scale, 0, 0));
            }
            else
            {
                region.autosize();
            }
        }
    }
}
项目:marathonv5    文件:DigitalClock.java   
public DigitalClock() {
    super(480, 412);
    // add background image
    ImageView background = new ImageView(new Image(getClass().getResourceAsStream("DigitalClock-background.png")));
    // add digital clock
    clock = new Clock(Color.ORANGERED, Color.rgb(50,50,50));
    clock.setLayoutX(45);
    clock.setLayoutY(186);
    clock.getTransforms().add(new Scale(0.83f, 0.83f, 0, 0));
    // add background and clock to sample
    getChildren().addAll(background, clock);
}
项目:marathonv5    文件:DigitalClock.java   
public DigitalClock() {
    super(480, 412);
    // add background image
    ImageView background = new ImageView(new Image(getClass().getResourceAsStream("DigitalClock-background.png")));
    // add digital clock
    clock = new Clock(Color.ORANGERED, Color.rgb(50,50,50));
    clock.setLayoutX(45);
    clock.setLayoutY(186);
    clock.getTransforms().add(new Scale(0.83f, 0.83f, 0, 0));
    // add background and clock to sample
    getChildren().addAll(background, clock);
}
项目:Gargoyle    文件:FxUtil.java   
/********************************
 * 작성일 : 2016. 6. 29. 작성자 : KYJ
 *
 * print 처리.
 *
 * @param window
 * @param target
 ********************************/
public static void printJob(Window window, Node target) {
    Printer printer = Printer.getDefaultPrinter();
    // PrinterAttributes printerAttributes = printer.getPrinterAttributes();
    //
    Paper a4 = Paper.A4;

    // Paper a4 = PrintHelper.createPaper("Rotate A4", Paper.A4.getHeight(),
    // Paper.A4.getWidth(), Units.MM);
    PageLayout pageLayout = printer.createPageLayout(a4, PageOrientation.REVERSE_PORTRAIT, MarginType.DEFAULT);

    PrinterJob printerJob = PrinterJob.createPrinterJob();

    // JobSettings jobSettings = printerJob.getJobSettings();
    // jobSettings.setPrintSides(PrintSides.TUMBLE);
    ImageView imageView = new ImageView();
    // 화면 사이즈에 맞게 크기 조절.
    Callback<SnapshotResult, Void> callback = param -> {
        final WritableImage image = param.getImage();
        imageView.setImage(image);

        final double scaleX = pageLayout.getPrintableWidth() / imageView.getBoundsInParent().getWidth();
        final double scaleY = pageLayout.getPrintableHeight() / imageView.getBoundsInParent().getHeight();
        imageView.getTransforms().add(new Scale(scaleX, scaleY));

        return null;
    };

    target.snapshot(callback, null, null);

    if (printerJob.showPrintDialog(window) && printerJob.printPage(pageLayout, imageView))
        printerJob.endJob();
}
项目:Gargoyle    文件:FxUtil.java   
public static void printDefefaultJob(Window window, Node target) {
    printJob(window, target, (param, imageView) -> {

        // ImageView imageView = new ImageView();
        final WritableImage image = param.getImage();
        imageView.setImage(image);

        // final double scaleX = pageLayout.getPrintableWidth() /
        // imageView.getBoundsInParent().getWidth();
        // final double scaleY = pageLayout.getPrintableHeight() /
        // imageView.getBoundsInParent().getHeight();
        imageView.getTransforms().add(new Scale(1, 1));

    });
}
项目:megan-ce    文件:PrintCommand.java   
public void apply(NexusStreamParser np) throws Exception {
        np.matchIgnoreCase(getSyntax());

        PrinterJob job = PrinterJob.createPrinterJob();
//        Paper customPaper = PrintHelper.createPaper("Custom", printImage.getLayoutBounds().getWidth(),
//                printImage.getLayoutBounds().getHeight(), Units.POINT);
//        PageLayout layout = pdfPrinter.createPageLayout(customPaper, PageOrientation.PORTRAIT, Printer.MarginType.HARDWARE_MINIMUM);
        // TODO: 30.05.2017 improve or wait until bug JDK-8088509 is fixed. Alternatively:
//        job.showPageSetupDialog(new Stage());
//        Paper paper = PrintHelper.createPaper("CustomSize", 600,400, Units.POINT);
        PageLayout layout = job.getPrinter().createPageLayout(Paper.A5, PageOrientation.LANDSCAPE, Printer.MarginType.DEFAULT);
//        job.showPageSetupDialog(stage);
        job.getJobSettings().setPageLayout(layout);

        final Node node = ((IHasJavaFXStageAndRoot) getViewer()).getJavaFXRoot();
        // Scale image to paper size (A4)
        double scaleX = layout.getPrintableWidth() / node.getLayoutBounds().getWidth();
        double scaleY = layout.getPrintableHeight() / node.getLayoutBounds().getHeight();
        if (scaleX > scaleY) {
            scaleX = scaleY;
        } else {
            scaleY = scaleX;
        }
        node.getTransforms().add(new Scale(scaleX, scaleY));

        boolean printSpooled = job.printPage(layout, node);
        if (printSpooled) {
            job.endJob();
            System.err.println("Wrote Image to PDF successfully");
        } else {
            throw new IOException("Error writing PDF.");
        }
        node.getTransforms().add(new Scale(1 / scaleX, 1 / scaleY));
    }
项目:Synth    文件:WorkspacePane.java   
/**
 * Add a component to the anchorpane and declare the dragging controls handlers
 */
public void addWithDragging(final ComponentPane component) {

    // Mandage drag and drop
    component.setOnDragDetected(event -> {
        // TODO: add component relocation
        final Dragboard db = component.startDragAndDrop(TransferMode.ANY);
        final ClipboardContent content = new ClipboardContent();

        final SnapshotParameters params = new SnapshotParameters();
        final Scale scale = new Scale();
        scale.setX(getScaleX());
        scale.setY(getScaleY());
        // FIXME: Work fot the minimum scale value but not for the maximum while zooming the anchorpane ?!
        final WritableImage image = component.snapshot(
                params,
                new WritableImage(
                        ((Double)(component.getWidth() * getScaleX())).intValue(),
                        ((Double)(component.getHeight() * getScaleY())).intValue()
                )
        );
        content.putImage(image);

        content.putString(DRAG_N_DROP_MOVE_GUARD);
        db.setContent(content);
        event.consume();
    });
    getChildren().add(component);
    CoreController.getConnectionManager().getHistory().add(component, StateType.CREATED);
}
项目:IEMLS    文件:EnvironmentView.java   
public void paintAgent(Agent agent) {
    Node node = agent.getVisualObject();
    Scale scale = new Scale();
    scale.setX(getZoom());
    scale.setY(getZoom());
    node.getTransforms().add(scale);
    node.setTranslateX(-getTranslation().getX() + agent.getPosition().getX() * getTileSize());
    node.setTranslateY(-getTranslation().getY() + agent.getPosition().getY() * getTileSize());
    getChildren().add(node);
}
项目:IEMLS    文件:EnvironmentView.java   
/**
 * Paint agents
 */
public void paintAgents() {
    for (Agent agent : getAgentsManager().getAgents()) {
        Node node = agent.getVisualObject();
        Scale scale = new Scale();
        scale.setX(getZoom());
        scale.setY(getZoom());
        node.getTransforms().add(scale);
        node.setTranslateX(-getTranslation().getX() + agent.getPosition().getX() * getTileSize());
        node.setTranslateY(-getTranslation().getY() + agent.getPosition().getY() * getTileSize());
        getChildren().add(node);
    }
}
项目:IEMLS    文件:EnvironmentView.java   
/**
 * Paint a object given a position
 * @param mapObject
 * @param x
 * @param y
 */
private void paintObject(MapObject mapObject, double x, double y) {
    Node node = mapObject.getVisualObject();
    Scale scale = new Scale();
    scale.setX(getZoom());
    scale.setY(getZoom());
    node.getTransforms().add(scale);
    node.setTranslateX(x * getTileSize() - (getTranslation().getX()) % getTileSize());
    node.setTranslateY(y * getTileSize() - (getTranslation().getY()) % getTileSize());
    getChildren().add(node);
}
项目:grapheditor    文件:GraphEditorDemoController.java   
/**
 * Initializes the menu bar.
 */
private void initializeMenuBar() {

    scaleTransform = new Scale(currentZoomFactor, currentZoomFactor, 0, 0);
    scaleTransform.yProperty().bind(scaleTransform.xProperty());

    graphEditor.getView().getTransforms().add(scaleTransform);

    final ToggleGroup skinGroup = new ToggleGroup();
    skinGroup.getToggles().addAll(defaultSkinButton, treeSkinButton, titledSkinButton);

    final ToggleGroup connectionStyleGroup = new ToggleGroup();
    connectionStyleGroup.getToggles().addAll(gappedStyleButton, detouredStyleButton);

    final ToggleGroup connectorTypeGroup = new ToggleGroup();
    connectorTypeGroup.getToggles().addAll(inputConnectorTypeButton, outputConnectorTypeButton);

    final ToggleGroup positionGroup = new ToggleGroup();
    positionGroup.getToggles().addAll(leftConnectorPositionButton, rightConnectorPositionButton);
    positionGroup.getToggles().addAll(topConnectorPositionButton, bottomConnectorPositionButton);

    graphEditor.getProperties().gridVisibleProperty().bind(showGridButton.selectedProperty());
    graphEditor.getProperties().snapToGridProperty().bind(snapToGridButton.selectedProperty());

    minimapButton.setGraphic(AwesomeIcon.MAP.node());

    initializeZoomOptions();

    final ListChangeListener<? super GNode> selectedNodesListener = change -> {
        checkConnectorButtonsToDisable();
    };

    graphEditor.getSelectionManager().getSelectedNodes().addListener(selectedNodesListener);
    checkConnectorButtonsToDisable();
}
项目:FXGL    文件:FXGLScene.java   
public void bindSize(DoubleProperty scaledWidth, DoubleProperty scaledHeight, DoubleProperty scaleRatioX, DoubleProperty scaleRatioY) {
    root.prefWidthProperty().bind(scaledWidth);
    root.prefHeightProperty().bind(scaledHeight);

    Scale scale = new Scale();
    scale.xProperty().bind(scaleRatioX);
    scale.yProperty().bind(scaleRatioY);
    root.getTransforms().setAll(scale);
}
项目: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;
}
项目:JFoenix    文件:JFXPopupSkin.java   
public JFXPopupSkin(JFXPopup control) {
    this.control = control;
    scale = new Scale(1, 0, 0, 0);
    popupContent = control.getPopupContent();
    container.getStyleClass().add("jfx-popup-container");
    container.setBackground(new Background(new BackgroundFill(Color.WHITE, CornerRadii.EMPTY, Insets.EMPTY)));
    container.getChildren().add(popupContent);
    container.getTransforms().add(scale);
    container.setOpacity(0);
    root = JFXDepthManager.createMaterialNode(container, 4);
    animation = getAnimation();
}
项目: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   
/**
 * Compute the transformation to be applied for the zoom.
 * @param zoom    the scale of the zoom.
 * @param center  the center of the zoom, in camera space
 * @return the transformation for the zoom.
 */
protected Transform computeZoom(double zoom, Point2D center) {
    Point2D world;
    Transform newScale = scale;
    try {
        world = scale.inverseTransform(center.getX() - toCenter.getX() - translate.getX(),
                center.getY() - toCenter.getY() - translate.getY());
        newScale = scale.createConcatenation(new Scale(zoom, zoom,
                                    world.getX(), world.getY()));
    } catch (NonInvertibleTransformException e) {
        e.printStackTrace();
    }
    return newScale;
}
项目: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));
}
项目:clarity-analyzer    文件:MapControl.java   
public MapControl() {
    mapImage = new Image(getClass().getResourceAsStream("/images/minimap_686.jpg"));

    double scale = getSize() / mapImage.getWidth();
    background = new ImageView(mapImage);
    background.getTransforms().add(new Scale(scale, scale));
    getChildren().add(background);

    icons = new Group();
    getChildren().add(icons);
}
项目: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));
}
项目: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    文件:JFXRepresentation.java   
/** Set zoom level
 *  @param zoom Zoom level: 1.0 for 100%, 0.5 for 50%, ZOOM_ALL, ZOOM_WIDTH, ZOOM_HEIGHT
 *  @return Zoom level actually used
 */
private double setZoom(double zoom)
{
    if (zoom <= 0.0)
    {   // Determine zoom to fit outline of display into available space
        final Bounds available = model_root.getLayoutBounds();
        final Bounds outline = widget_parent.getLayoutBounds();
        final double zoom_x = outline.getWidth()  > 0 ? available.getWidth()  / outline.getWidth() : 1.0;
        final double zoom_y = outline.getHeight() > 0 ? available.getHeight() / outline.getHeight() : 1.0;

        if (zoom == ZOOM_WIDTH)
            zoom = zoom_x;
        else if (zoom == ZOOM_HEIGHT)
            zoom = zoom_y;
        else // Assume ZOOM_ALL
            zoom = Math.min(zoom_x, zoom_y);
    }

    widget_parent.getTransforms().setAll(new Scale(zoom, zoom));
    // Appears similar to using this API:
    //     widget_parent.setScaleX(zoom);
    //     widget_parent.setScaleY(zoom);
    // but when resizing the window,
    // using setScaleX/Y results in sluggish updates,
    // sometimes shifting the content around
    // (top left origin of content no longer in top left corner of window).
    // Setting a Scale() transform does not exhibit that quirk,
    // maybe because both X and Y scaling are set 'at once'?

    if (isEditMode())
        updateModelSizeIndicators();

    return zoom;
}
项目:org.csstudio.display.builder    文件:JFXRepresentation.java   
/** @return Zoom factor, 1.0 for 1:1 */
public double getZoom()
{
    final List<Transform> transforms = widget_parent.getTransforms();
    if (transforms.isEmpty()  ||
        transforms.size() > 1 ||
        ! (transforms.get(0) instanceof Scale))
        return 1.0;
    // Have one 'scale'
    final Scale scale = (Scale) transforms.get(0);
    // Expect scaling in X == Y, but just in case return average
    return ( scale.getX() + scale.getY() ) / 2.0;
}
项目:contentment    文件:ScaleListener.java   
@Override
public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue)
{
    final double newWidth = host.getWidth();
    media.setFitWidth(newWidth);
    final double newHeight = host.getHeight();
    double scaleFactor = newWidth / newHeight > 16d / 9d ? newHeight / 900d : newWidth / 1600d;
    Scale newScale = new Scale(scaleFactor, scaleFactor);
    newScale.setPivotX(0);
    newScale.setPivotY(0);
    child.getTransforms().setAll(newScale);
}
项目:fx-jumpman    文件:View.java   
public void initializeView() {
    root = new AnchorPane();
    view = new Group();

    Scale viewScale = Transform.scale(1, 1, 0, 0);
    viewScale.xProperty().bind(root.widthProperty().divide(View.WIDTH));
    viewScale.yProperty().bind(root.heightProperty().divide(View.HEIGHT));
    view.getTransforms().add(viewScale);

    view.setFocusTraversable(true);
    view.addEventHandler(KeyEvent.ANY, new Controller());

    root.getChildren().add(view);

    Text info = TextBuilder.create()
            .text("Esc: Help\nR: Reset")
            .font(Font.font("Arial", FontWeight.BOLD, 16))
            .fill(Color.WHITE)
            .build();
    AnchorPane.setTopAnchor(info, 20.0);
    AnchorPane.setRightAnchor(info, 20.0);

    root.getChildren().add(info);

    Text time = TextBuilder.create()
            .font(Font.font("Arial", FontWeight.BOLD, 16))
            .fill(Color.WHITE)
            .build();
    time.textProperty().bind(Bindings.concat("Time: ", Bindings.format("%.2f", World.getInstance().levelTimeProperty()), " seconds"));

    AnchorPane.setTopAnchor(time, 20.0);
    AnchorPane.setLeftAnchor(time, 20.0);

    root.getChildren().add(time);

    help = new Help();
    root.getChildren().add(help);
}
项目: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));
}
项目:exchange    文件:StaticProgressIndicatorSkin.java   
@Override
protected void layoutChildren() {
    // calculate scale
    double scale = getWidth() / computePrefWidth(-1);
    getChildren().stream().filter(child -> child instanceof Region).forEach(child -> {
        Region region = (Region) child;
        if (region.getShape() != null) {
            region.resize(region.getShape().getLayoutBounds().getMaxX(),
                    region.getShape().getLayoutBounds().getMaxY());
            region.getTransforms().setAll(new Scale(scale, scale, 0, 0));
        } else {
            region.autosize();
        }
    });
}
项目:graph-editor    文件:GraphEditorDemoController.java   
/**
 * Initializes the menu bar.
 */
private void initializeMenuBar() {

    scaleTransform = new Scale(currentZoomFactor, currentZoomFactor, 0, 0);
    scaleTransform.yProperty().bind(scaleTransform.xProperty());

    graphEditor.getView().getTransforms().add(scaleTransform);

    final ToggleGroup skinGroup = new ToggleGroup();
    skinGroup.getToggles().addAll(defaultSkinButton, treeSkinButton, titledSkinButton);

    final ToggleGroup connectionStyleGroup = new ToggleGroup();
    connectionStyleGroup.getToggles().addAll(gappedStyleButton, detouredStyleButton);

    final ToggleGroup connectorTypeGroup = new ToggleGroup();
    connectorTypeGroup.getToggles().addAll(inputConnectorTypeButton, outputConnectorTypeButton);

    final ToggleGroup positionGroup = new ToggleGroup();
    positionGroup.getToggles().addAll(leftConnectorPositionButton, rightConnectorPositionButton);
    positionGroup.getToggles().addAll(topConnectorPositionButton, bottomConnectorPositionButton);

    graphEditor.getProperties().gridVisibleProperty().bind(showGridButton.selectedProperty());
    graphEditor.getProperties().snapToGridProperty().bind(snapToGridButton.selectedProperty());

    minimapButton.setGraphic(AwesomeIcon.MAP.node());

    initializeZoomOptions();

    final ListChangeListener<? super GNode> selectedNodesListener = change -> {
        checkConnectorButtonsToDisable();
    };

    graphEditor.getSelectionManager().getSelectedNodes().addListener(selectedNodesListener);
    checkConnectorButtonsToDisable();
}
项目:PiOnWheels    文件:ScalableContentPane.java   
/**
     * Defines the content pane of this scalable pane.
     *
     * @param contentPane pane to define
     */
    public final void setContent(Pane contentPane) {
        contentPaneProperty.setValue(contentPane);
        contentPane.setManaged(false);
        initContentPaneListener();
//        contentPane.setStyle("-fx-border-color: rgb(0,0,0);");

        contentScaleTransform = new Scale(1, 1);
        getContentScaleTransform().setPivotX(0);
        getContentScaleTransform().setPivotY(0);
        getContentScaleTransform().setPivotZ(0);
        getContent().getTransforms().add(getContentScaleTransform());

        getChildren().add(contentPane);

        ChangeListener<Number> changeListener = new ChangeListener<Number>() {

            @Override
            public void changed(ObservableValue<? extends Number> observable, Number oldValue, Number newValue) {
                requestScale();
            }
        };

        minScaleXProperty().addListener(changeListener);
        minScaleYProperty().addListener(changeListener);
        maxScaleXProperty().addListener(changeListener);
        maxScaleYProperty().addListener(changeListener);


//        getContentPane().setStyle("-fx-border-color: red; -fx-border-width: 1;");
    }
项目: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;
}