public static void addRotate(Node node, Point3D rotationAxis, double angle) { ObservableList<Transform> transforms = node.getTransforms(); try { for (Transform t : transforms) { rotationAxis = t.inverseDeltaTransform(rotationAxis); } } catch (NonInvertibleTransformException ex) { throw new IllegalStateException(ex); } transforms.add(new Rotate(angle, rotationAxis)); }
public MouseBehaviorImpl1(Node n, MouseButton btn) { n.getTransforms().addAll(rotateX, rotateZ); this.btn = btn; if (btn == null) { this.btn = MouseButton.MIDDLE; } }
public static void transformNode(Node nodeToTransform, RigidBodyTransform transform) { nodeToTransform.getTransforms().add(JavaFXTools.convertRigidBodyTransformToAffine(transform)); }
public SimpleCameraMouseEventHandler(Node cameraNode) { cameraNode.getTransforms().addAll(xRotate, yRotate); }
public SimpleCameraMouseEventHandler(Node cameraNode) { cameraNode.getTransforms().addAll(xRotate, yRotate); }
public static void printNode(final Node node) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException { Printer printer = Printer.getDefaultPrinter(); PageLayout pageLayout = printer.createPageLayout(Paper.A4, PageOrientation.PORTRAIT, Printer.MarginType.HARDWARE_MINIMUM); PrinterAttributes attr = printer.getPrinterAttributes(); PrinterJob job = PrinterJob.createPrinterJob(); double scaleX = pageLayout.getPrintableWidth() / node.getBoundsInParent().getWidth(); double scaleY = pageLayout.getPrintableHeight() / node.getBoundsInParent().getHeight(); Scale scale = new Scale(scaleX, scaleY); node.getTransforms().add(scale); if (job != null && job.showPrintDialog(node.getScene().getWindow())) { boolean success = job.printPage(pageLayout, node); if (success) { job.endJob(); } } node.getTransforms().remove(scale); }
private void updateTransformsText() { final List<Transform> transforms = this.getContentGroup().getTransforms(); this.setTransformText(transformsToString(transforms)); }
public void print(final Node node) { Printer printer = Printer.getDefaultPrinter(); PageLayout pageLayout = printer.createPageLayout(Paper.NA_LETTER, PageOrientation.PORTRAIT, Printer.MarginType.DEFAULT); double scaleX = pageLayout.getPrintableWidth() / node.getBoundsInParent().getWidth(); double scaleY = pageLayout.getPrintableHeight() / node.getBoundsInParent().getHeight(); node.getTransforms().add(new Scale(scaleX, scaleY)); PrinterJob job = PrinterJob.createPrinterJob(); if (job != null) { boolean success = job.printPage(node); if (success) { job.endJob(); } } }
private void optimize(Node node) { ObservableList<Transform> transforms = node.getTransforms(); Iterator<Transform> iterator = transforms.iterator(); boolean prevIsStatic = false;
private void resetTransforms() { getContentGroup().getTransforms().clear(); getContentGroup().getTransforms().addAll(getTmain(), getRxmain(), getRymain(), getRzmain()); setupTransforms(); }
node.getTransforms().add(new Scale(scale, scale));
this.getContentGroup().getTransforms().add(0, getRxy()); this.getContentGroup().getTransforms().add(getRxy()); this.setRz(new Rotate(0, Rotate.Z_AXIS)); if (leftMultiplySelected) { this.getContentGroup().getTransforms().add(0, getRz()); } else { this.getContentGroup().getTransforms().add(getRz()); this.setT(new Translate()); if (leftMultiplySelected) { this.getContentGroup().getTransforms().add(0, getT()); } else { this.getContentGroup().getTransforms().add(getT()); this.setT(new Translate()); if (leftMultiplySelected) { this.getContentGroup().getTransforms().add(0, getT()); } else { this.getContentGroup().getTransforms().add(getT()); this.setS(new Scale()); if (leftMultiplySelected) { this.getContentGroup().getTransforms().add(0, getS()); } else { this.getContentGroup().getTransforms().add(getS());
for (Transform t : node.getTransforms()) { if (t instanceof Rotate) { r = (Rotate)t; for (Transform t : node.getTransforms()) { if (t instanceof Scale) { s = (Scale)t;
node.getTransforms().add(new Translate(-x,-y)); node.setTranslateX(x); node.setTranslateY(y);
public AssertNode assertRotate(double x, double y, double angle, double accuracy) { Rotate r = null; for (Transform t : node.getTransforms()) { if (t instanceof Rotate) { r = (Rotate)t; break; } } Assert.assertEquals(description + ", PivotX", x, r.getPivotX(), accuracy); Assert.assertEquals(description + ", PivotY", y, r.getPivotY(), accuracy); Assert.assertEquals(description + ", Angle", angle, r.getAngle(), accuracy); return this; }
public AssertNode assertScale(double x, double y, double scaleX, double scaleY, double accuracy) { Scale s = null; for (Transform t : node.getTransforms()) { if (t instanceof Scale) { s = (Scale)t; break; } } Assert.assertEquals(description + ", PivotX", x, s.getPivotX(), accuracy); Assert.assertEquals(description + ", PivotY", y, s.getPivotY(), accuracy); Assert.assertEquals(description + ", X", scaleX, s.getX(), accuracy); Assert.assertEquals(description + ", Y", scaleY, s.getY(), accuracy); return this; }
rx.setAngle(Math.toDegrees( -angle1)); node.getTransforms().addAll(rx);
/** * Prints a node.<br> * The user selects the printer and the node is scaled down if too large for the paper. * * @param node the node to print */ public void print(Node node) { PrinterJob job = PrinterJob.createPrinterJob(); if (job != null && job.showPrintDialog(Fx.getStage(node))) { PageLayout pageLayout = job.getJobSettings().getPageLayout(); double scaleX = 1.0; if (pageLayout.getPrintableWidth() < node.getBoundsInParent().getWidth()) { scaleX = pageLayout.getPrintableWidth() / node.getBoundsInParent().getWidth(); } double scaleY = 1.0; if (pageLayout.getPrintableHeight() < node.getBoundsInParent().getHeight()) { scaleY = pageLayout.getPrintableHeight() / node.getBoundsInParent().getHeight(); } double scaleXY = Double.min(scaleX, scaleY); Scale scale = new Scale(scaleXY, scaleXY); node.getTransforms().add(scale); boolean success = job.printPage(node); node.getTransforms().remove(scale); if (success) { job.endJob(); } } }
@Override public void run() { node.getTransforms().addAll(xRotate, yRotate); scene.setOnMousePressed(e -> { mousePoint = new Point2D(e.getSceneX(), e.getSceneY()); }); scene.setOnZoom((e) -> { System.out.println(node.getTranslateZ()); node.setTranslateZ(node.getTranslateZ() + (1.0 - e.getZoomFactor()) * 100); }); scene.setOnMouseDragged(e -> { double mouseDeltaX = (e.getSceneX() - mousePoint.getX()); double mouseDeltaY = (e.getSceneY() - mousePoint.getY()); mousePoint = new Point2D(e.getSceneX(), e.getSceneY()); xRotate.setAngle(xRotate.getAngle() - mouseDeltaY * 0.1 * 2.0); yRotate.setAngle(yRotate.getAngle() + mouseDeltaX * 0.1 * 2.0); }); } }.run();
@Override public void run() { node.getTransforms().addAll(xRotate, yRotate); scene.setOnMousePressed(e -> { mousePoint = new Point2D(e.getSceneX(), e.getSceneY()); }); scene.setOnZoom((e) -> { System.out.println(node.getTranslateZ()); node.setTranslateZ(node.getTranslateZ() + (1.0 - e.getZoomFactor()) * 100); }); scene.setOnMouseDragged(e -> { double mouseDeltaX = (e.getSceneX() - mousePoint.getX()); double mouseDeltaY = (e.getSceneY() - mousePoint.getY()); mousePoint = new Point2D(e.getSceneX(), e.getSceneY()); xRotate.setAngle(xRotate.getAngle() - mouseDeltaY * 0.1 * 2.0); yRotate.setAngle(yRotate.getAngle() + mouseDeltaX * 0.1 * 2.0); }); } }.run();