当前位置: 首页>>代码示例>>Java>>正文


Java Transform类代码示例

本文整理汇总了Java中javafx.scene.transform.Transform的典型用法代码示例。如果您正苦于以下问题:Java Transform类的具体用法?Java Transform怎么用?Java Transform使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Transform类属于javafx.scene.transform包,在下文中一共展示了Transform类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testGestureDisabling

import javafx.scene.transform.Transform; //导入依赖的package包/类
@Test
public void testGestureDisabling() throws Exception {
	pane.setGestureEnabled(false);
	pane.zoomTo(2, pane.targetPointAtViewportCentre());
	Transform expected = target.captureTransform();
	FxRobot robot = new FxRobot();
	robot.moveTo(pane)
			.scroll(2, VerticalDirection.UP)
			.scroll(2, VerticalDirection.DOWN)
			.drag(MouseButton.PRIMARY).dropBy(100, 100);
	assertThat(target.captureTransform()).isEqualToComparingOnlyGivenFields(expected,
			"xx", "xy", "xz",
			"yx", "yy", "yz",
			"zx", "zy", "zz",
			"xt", "yt", "zt");
}
 
开发者ID:tom91136,项目名称:GestureFX,代码行数:17,代码来源:GesturePaneTest.java

示例2: initialize

import javafx.scene.transform.Transform; //导入依赖的package包/类
public void initialize() 
{
   // points that define a five-pointed star shape
   Double[] points = {205.0,150.0, 217.0,186.0, 259.0,186.0, 
      223.0,204.0, 233.0,246.0, 205.0,222.0, 177.0,246.0, 187.0,204.0, 
      151.0,186.0, 193.0,186.0};
   
   // create 18 more stars
   for (int count = 0; count < 18; ++count)
   {
      // create a new Polygon and copy existing points into it
      Polygon newStar = new Polygon();
      newStar.getPoints().addAll(points); 

      // create random Color and set as newStar's fill
      newStar.setStroke(Color.GREY);
      newStar.setFill(Color.rgb(random.nextInt(255), 
         random.nextInt(255), random.nextInt(255), 
         random.nextDouble())); 

      // apply a rotation to the shape
      newStar.getTransforms().add(
         Transform.rotate(count * 20, 150, 150));
      anchorPane.getChildren().add(newStar);
   } 
}
 
开发者ID:cleitonferreira,项目名称:LivroJavaComoProgramar10Edicao,代码行数:27,代码来源:DrawStarsController.java

示例3: setupTransforms

import javafx.scene.transform.Transform; //导入依赖的package包/类
/**
 * sets up transforming of selections
 */
private void setupTransforms() {
    viewTransformProperty = new SimpleObjectProperty<>(new Transform() {
        @Override
        public void impl_apply(Affine3D t) {

        }

        @Override
        public BaseTransform impl_derive(BaseTransform t) {
            return null;
        }
    });
    viewTransformProperty.addListener((observable, oldValue, newValue) -> {
        myGraphView.getTransforms().setAll(newValue);
    });
}
 
开发者ID:jmueller95,项目名称:CORNETTO,代码行数:20,代码来源:ViewPane.java

示例4: testDragAndDrop

import javafx.scene.transform.Transform; //导入依赖的package包/类
@Test
public void testDragAndDrop() throws Exception {
	pane.zoomTo(2, pane.targetPointAtViewportCentre());
	Transform expected = target.captureTransform();
	FxRobot robot = new FxRobot();
	robot.moveTo(pane)
			.drag(MouseButton.PRIMARY).dropBy(100, 100);
	Transform actual = target.captureTransform();
	assertThat(actual).isEqualToComparingOnlyGivenFields(expected,
			"xx", "xy", "xz",
			"yx", "yy", "yz",
			"zx", "zy", "zz",
			/* "xt", "yt", */ "zt"); // x y will have delta
	assertThat(actual.getTx()).isCloseTo(expected.getTx() + 100, Offset.offset(10d));
	assertThat(actual.getTy()).isCloseTo(expected.getTy() + 100, Offset.offset(10d));
}
 
开发者ID:tom91136,项目名称:GestureFX,代码行数:17,代码来源:GesturePaneTest.java

示例5: testScaleByScroll

import javafx.scene.transform.Transform; //导入依赖的package包/类
@Test
public void testScaleByScroll() throws Exception {
	pane.scrollModeProperty().set(ScrollMode.ZOOM);
	pane.zoomTo(5, pane.targetPointAtViewportCentre());
	FxRobot robot = new FxRobot();
	assertThat(pane.getCurrentXScale()).isEqualTo(5d);
	Thread.sleep(100);
	robot.moveTo(pane);
	robot.scroll(5, VerticalDirection.UP); // direction is platform dependent
	Thread.sleep(100);
	double expectedUp = 5 * Math.pow(1 + DEFAULT_SCROLL_FACTOR, 5);
	double expectedDown = 5 * Math.pow(1 - DEFAULT_SCROLL_FACTOR, 5);

	Condition<Double> eitherUpOrDown = new Condition<>(
			v -> Math.abs(v - expectedUp) < 0.01 || Math.abs(v - expectedDown) < 0.01,
			                                                  "either close to %s or %s",
			                                                  expectedUp, expectedDown);
	assertThat(pane.getCurrentXScale()).is(eitherUpOrDown);
	Transform t = target.captureTransform();
	assertThat(t.getMxx()).is(eitherUpOrDown);
	assertThat(t.getMyy()).is(eitherUpOrDown);
}
 
开发者ID:tom91136,项目名称:GestureFX,代码行数:23,代码来源:GesturePaneTest.java

示例6: createFromSvg

import javafx.scene.transform.Transform; //导入依赖的package包/类
public static Ellipse createFromSvg(Element element) throws MalformedParametersException {
    if (!element.getName().toLowerCase().trim().equals("ellipse")) {
        throw new MalformedParametersException("SVG Element is not an Ellipse.");
    }

    Ellipse ellipse = new Ellipse();

    ellipse.setCenterX(Double.parseDouble(element.getAttributeValue("cx")));
    ellipse.setCenterY(Double.parseDouble(element.getAttributeValue("cy")));
    ellipse.setRadiusX(Double.parseDouble(element.getAttributeValue("rx")));
    ellipse.setRadiusY(Double.parseDouble(element.getAttributeValue("ry")));

    ellipse.setFill(Color.web(element.getAttributeValue("fill"), Double.parseDouble(element.getAttributeValue("fill-opacity"))));

    ellipse.setStroke(Color.web(element.getAttributeValue("stroke"), Double.parseDouble(element.getAttributeValue("stroke-opacity"))));
    ellipse.setStrokeWidth(Double.parseDouble(element.getAttributeValue("stroke-width")));

    String svgTransforms = element.getAttributeValue("transform");

    if (svgTransforms != null) {
        List<Transform> transforms = ShapeUtils.getTransformsFromSvg(svgTransforms);
        ellipse.getTransforms().addAll(transforms);
    }

    return ellipse;
}
 
开发者ID:pfolta,项目名称:Shapify,代码行数:27,代码来源:Ellipse.java

示例7: createFromSvg

import javafx.scene.transform.Transform; //导入依赖的package包/类
public static Line createFromSvg(Element element) throws MalformedParametersException {
    if (!element.getName().toLowerCase().trim().equals("line")) {
        throw new MalformedParametersException("SVG Element is not a Line.");
    }

    Line line = new Line();

    line.setStartX(Double.parseDouble(element.getAttributeValue("x1")));
    line.setStartY(Double.parseDouble(element.getAttributeValue("y1")));
    line.setEndX(Double.parseDouble(element.getAttributeValue("x2")));
    line.setEndY(Double.parseDouble(element.getAttributeValue("y2")));

    line.setStroke(Color.web(element.getAttributeValue("stroke"), Double.parseDouble(element.getAttributeValue("stroke-opacity"))));
    line.setStrokeWidth(Double.parseDouble(element.getAttributeValue("stroke-width")));

    String svgTransforms = element.getAttributeValue("transform");

    if (svgTransforms != null) {
        List<Transform> transforms = ShapeUtils.getTransformsFromSvg(svgTransforms);
        line.getTransforms().addAll(transforms);
    }

    return line;
}
 
开发者ID:pfolta,项目名称:Shapify,代码行数:25,代码来源:Line.java

示例8: createFromSvg

import javafx.scene.transform.Transform; //导入依赖的package包/类
public static Image createFromSvg(Element element) throws MalformedParametersException {
    if (!element.getName().toLowerCase().trim().equals("image")) {
        throw new MalformedParametersException("SVG Element is not a Rectangle.");
    }

    Image image = new Image();

    image.setImage(getImageFromBase64(element.getAttributeValue("href", SvgController.XLINK_NAMESPACE)));

    image.setX(Double.parseDouble(element.getAttributeValue("x")));
    image.setY(Double.parseDouble(element.getAttributeValue("y")));
    image.setFitWidth(Double.parseDouble(element.getAttributeValue("width")));
    image.setFitHeight(Double.parseDouble(element.getAttributeValue("height")));

    String svgTransforms = element.getAttributeValue("transform");

    if (svgTransforms != null) {
        List<Transform> transforms = ShapeUtils.getTransformsFromSvg(svgTransforms);
        image.getTransforms().addAll(transforms);
    }

    return image;
}
 
开发者ID:pfolta,项目名称:Shapify,代码行数:24,代码来源:Image.java

示例9: createFromSvg

import javafx.scene.transform.Transform; //导入依赖的package包/类
public static Rectangle createFromSvg(Element element) throws MalformedParametersException {
    if (!element.getName().toLowerCase().trim().equals("rect")) {
        throw new MalformedParametersException("SVG Element is not a Rectangle.");
    }

    Rectangle rectangle = new Rectangle();

    rectangle.setX(Double.parseDouble(element.getAttributeValue("x")));
    rectangle.setY(Double.parseDouble(element.getAttributeValue("y")));
    rectangle.setWidth(Double.parseDouble(element.getAttributeValue("width")));
    rectangle.setHeight(Double.parseDouble(element.getAttributeValue("height")));

    rectangle.setFill(Color.web(element.getAttributeValue("fill"), Double.parseDouble(element.getAttributeValue("fill-opacity"))));

    rectangle.setStroke(Color.web(element.getAttributeValue("stroke"), Double.parseDouble(element.getAttributeValue("stroke-opacity"))));
    rectangle.setStrokeWidth(Double.parseDouble(element.getAttributeValue("stroke-width")));

    String svgTransforms = element.getAttributeValue("transform");

    if (svgTransforms != null) {
        List<Transform> transforms = ShapeUtils.getTransformsFromSvg(svgTransforms);
        rectangle.getTransforms().addAll(transforms);
    }

    return rectangle;
}
 
开发者ID:pfolta,项目名称:Shapify,代码行数:27,代码来源:Rectangle.java

示例10: differentParentAndSceneTransforms

import javafx.scene.transform.Transform; //导入依赖的package包/类
@Test
public void differentParentAndSceneTransforms()
{
    Node node = circleTwoWrap.getControl();
    Transform localToScene = node.localToSceneTransformProperty().getValue();
    Transform localToParent = node.localToParentTransformProperty().getValue();

    realTranform.setTx(node.getTranslateX() + node.getLayoutX());
    realTranform.setTy(node.getTranslateY() + node.getLayoutY());
    realTranform.setTz(0);

    Assert.assertFalse(isTransformsEqual(localToParent, localToScene));
    Assert.assertTrue(isTransformsEqual(localToParent, realTranform));

    realTranform.setTx(node.getTranslateX() + node.getLayoutX() +
            node.getParent().getTranslateX() + node.getParent().getLayoutX());
    realTranform.setTy(node.getTranslateY() + node.getLayoutY() +
            node.getParent().getTranslateY() + node.getParent().getLayoutY());

    Assert.assertTrue(isTransformsEqual(localToScene, realTranform));
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:22,代码来源:LocalTo_TransformsTest.java

示例11: doubleNestedNodeParentAndSceneTransforms

import javafx.scene.transform.Transform; //导入依赖的package包/类
@Test
public void doubleNestedNodeParentAndSceneTransforms()
{
    Node node = circleThreeWrap.getControl();
    Transform localToScene = node.localToSceneTransformProperty().getValue();
    Transform localToParent = node.localToParentTransformProperty().getValue();

    realTranform.setTx(node.getTranslateX() + node.getLayoutX());
    realTranform.setTy(node.getTranslateY() + node.getLayoutY());
    realTranform.setTz(0);

    Assert.assertFalse(isTransformsEqual(localToParent, localToScene));
    Assert.assertTrue(isTransformsEqual(localToParent, realTranform));

    double tx = 0, ty = 0;
    for(Node n = node; n != null; n = n.getParent())
    {
        tx += n.getTranslateX() + n.getLayoutX();
        ty += n.getTranslateY() + n.getLayoutY();
    }
    realTranform.setTx(tx);
    realTranform.setTy(ty);

    Assert.assertTrue(isTransformsEqual(localToScene, realTranform));
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:26,代码来源:LocalTo_TransformsTest.java

示例12: parentAndScene3DTransforms

import javafx.scene.transform.Transform; //导入依赖的package包/类
@Test
public void parentAndScene3DTransforms()
{
    Node node = circleFourWrap.getControl();
    Transform localToScene = node.localToSceneTransformProperty().getValue();
    Transform localToParent = node.localToParentTransformProperty().getValue();

    realTranform.setTx(node.getTranslateX() + node.getLayoutX());
    realTranform.setTy(node.getTranslateY() + node.getLayoutY());
    realTranform.setTz(node.getTranslateZ());

    Assert.assertFalse(isTransformsEqual(localToParent, localToScene));
    Assert.assertTrue(isTransformsEqual(localToParent, realTranform));

    double tx = 0, ty = 0;
    for(Node n = node; n != null; n = n.getParent())
    {
        tx += n.getTranslateX() + n.getLayoutX();
        ty += n.getTranslateY() + n.getLayoutY();
    }
    realTranform.setTx(tx);
    realTranform.setTy(ty);

    Assert.assertTrue(isTransformsEqual(localToScene, realTranform));
}
 
开发者ID:teamfx,项目名称:openjfx-8u-dev-tests,代码行数:26,代码来源:LocalTo_TransformsTest.java

示例13: updateCanvasBinding

import javafx.scene.transform.Transform; //导入依赖的package包/类
private void updateCanvasBinding() {
        if (canvas == null || jfxRegion == null)
            return;
        Jfx.runOnSwing(() -> {
            Transform transform = jfxRegion.localToSceneTransformProperty().getValue();
            int width = jfxRegion.widthProperty().intValue();
            int height = jfxRegion.heightProperty().intValue();
            int localX = (int) transform.getTx();
            int localY = (int) transform.getTy();
//            System.out.println("resizeCanvasSize, width=" + jfxRegion.widthProperty().intValue() 
//                    + ", height=" + jfxRegion.heightProperty().intValue()
//                    + ", locationX=" + transform.getTx()
//                    + ", locationY=" + transform.getTy()
//            );
            canvas.setSize(width, height);
            canvas.setLocation(localX, localY);
        });
    }
 
开发者ID:huliqing,项目名称:LuoYing,代码行数:19,代码来源:CanvasJfxBindingController.java

示例14: export

import javafx.scene.transform.Transform; //导入依赖的package包/类
@Override
public WritableImage export(int width, int height) {
    VBox root = new VBox();
    root.setStyle("-fx-background-color: transparent;");
    root.setPadding(new Insets(25));
    
    root.getChildren().add(generate(false));         
    
    Stage newStage = new Stage();
    newStage.initModality(Modality.NONE);
    newStage.setScene(new Scene(root, width, height));
    newStage.setResizable(false);       
    newStage.show();
    
    SnapshotParameters sp = new SnapshotParameters();
    sp.setTransform(Transform.scale(width / root.getWidth(), height / root.getHeight()));
    newStage.close();
    
    return root.snapshot(sp, null);
}
 
开发者ID:deadlocker8,项目名称:BudgetMaster,代码行数:21,代码来源:MonthLineChart.java

示例15: ExportSvg

import javafx.scene.transform.Transform; //导入依赖的package包/类
@Override
  public String ExportSvg(int width, int height)
  {
if (Overlay == null) return "";
if (!Overlay.IsEnabled) return "";

Transform matrix = GetTransformation(width, height);

return String.format("<g transform=\"matrix(%.3f,%.3f,%.3f,%.3f,%.3f,%.3f)\">%s</g>",
	matrix.getMxx(),
	matrix.getMxy(),
	matrix.getMyx(),
	matrix.getMyy(),
	matrix.getTx(),
	matrix.getTy(),
	Overlay.ExportSvg(width, height));
  }
 
开发者ID:andrewsarnold,项目名称:FlagMaker-2,代码行数:18,代码来源:OverlayTransformer.java


注:本文中的javafx.scene.transform.Transform类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。