JavaFX. Oracle JavaFX Applying Transformations in JavaFX Release 2.1 E

Similar documents
JavaFX. JavaFX System Requirements Release E

Copyright 1998, 2009, Oracle and/or its affiliates. All rights reserved.

Defining Constants and Variables for Oracle Java CAPS Environments

Oracle Hospitality OPERA Exchange Interface Cloud Authentication. October 2017

New Features in Primavera Professional 15.2

Oracle Communications Configuration Management

1 Understanding the Cross Reference Facility

Report Management and Editor!

Importing an SNA Custom Handshake Class

JavaFX. JavaFX System Requirements Release E

Materials Control. Account Classes. Product Version Account Classes. Document Title: Joerg Trommeschlaeger

PeopleSoft Fluid Required Fields Standards

Oracle Hospitality Query and Analysis Languages and Translation Configuration Guide. March 2016

JavaFX. JavaFX 2.2 System Requirements Release 2.2 E

Oracle Utilities Advanced Spatial and Operational Analytics

Oracle Retail MICROS Stores2 Functional Document Sales - Receipt List Screen Release September 2015

JD Edwards EnterpriseOne. Overview. Prerequisites. Web Client for ipad Quick Start Guide Release 8.98 Update 4, Service Pack 5

Oracle Enterprise Manager

Recipe Calculation Survey. Materials Control. Copyright by: MICROS-FIDELIO GmbH Europadamm 2-6 D Neuss Date: August 21 st 2007.

Database Change Reference Release 6.3

Oracle Banking Channels Bank User Base

Oracle Hospitality MICROS Commerce Platform Release Notes Release Part Number: E December 2015

General Security Principles

Oracle Hospitality Suite8 Export to Outlook User Manual Release 8.9. July 2015

What s New for Cloud at Customer What's New for the Cloud Services on Oracle Cloud at Customer New Documentation for Oracle Cloud at Customer

Oracle Utilities Work and Asset Management Integration to Primavera P6 Enterprise Project Portfolio Management

Oracle Tuxedo Mainframe Adapter for SNA

Oracle Utilities Opower Custom URL Configuration

PeopleSoft Fluid Icon Standards

Oracle Database Firewall. 1 Downloading the Latest Version of This Document. 2 Known Issues. Release Notes Release 5.

Oracle WebCenter Portal. Starting Points for Oracle WebCenter Portal Installation

Oracle Enterprise Manager Ops Center

JD Edwards EnterpriseOne Licensing

Oracle Enterprise Manager Ops Center. Introduction. What You Will Need

Oracle Utilities Work and Asset Management

Oracle Enterprise Manager Ops Center. Introduction. Creating Oracle Solaris 11 Zones Guide 12c Release 1 ( )

OKM Key Management Appliance

Oracle Enterprise Manager Ops Center. Introduction. What You Will Need. Hardware and Software Configuration

Oracle Enterprise Data Quality for Product Data

What s New for Oracle Cloud Stack Manager. Topics: July Oracle Cloud. What's New for Oracle Cloud Stack Release

Oracle Argus Safety. 1 Configuration. 1.1 Configuring a Reporting Destination for the emdr Profile. emdr Best Practices Document Release 8.0.

JavaFX. Working with the JavaFX Scene Graph Release 8 E March 2014 Learn about the concept of a scene graph and how it is used in JavaFX.

Oracle Enterprise Manager Ops Center. Introduction. What You Will Need. Installing and Updating Local Software Packages 12c Release

Oracle Utilities Work and Asset Management

Oracle Linux. UEFI Secure Boot Signing Key Update Notice

Oracle Hospitality Cruise Shipboard Property Management System Topaz Signature Device Installation Guide Release 8.00 E

Oracle Hospitality BellaVita Hardware Requirements. June 2016

Oracle Communications Policy Management Configuring NetBackup for Upgrade Method of Procedure

Oracle Payment Interface Installation and Reference Guide Release E April 2018

Configuring Oracle Java CAPS Master Index (Repository) Connectivity and Environments

Managing Zone Configuration

StorageTek Enterprise Library Software

Oracle Enterprise Single Sign-on Logon Manager How-To: Configuring ESSO-LM Event Logging with Microsoft SQL Server 2005 Release

Oracle Enterprise Manager Ops Center. Introduction. What You Will Need. Creating vservers 12c Release 1 ( )

Oracle Retail MICROS Stores2 Functional Document Stores2 for Portugal Disaster Recovery Release

Oracle Endeca Commerce Compatibility Matrix

BAA Oracle EBS R12.1 isupplier Portal Created on 11/26/2012 3:18:00 PM

Security Guide Release 4.0

Oracle Endeca Guided Search Compatibility Matrix

Oracle. Field Service Cloud Using the Parts Catalog

Materials Control Recipe Reduction based on Article Defaults

Oracle Utilities Meter Data Management Release Utility Reference Model Maintain Generic Usage Subscription

SunDual Port 4x QDR IB Host Channel Adapter PCIe ExpressModule

Oracle Fusion Middleware Oracle Stream Analytics Release Notes. 12c Release ( )

Oracle Hospitality Suite8 XML Export of Invoice Data for Hungarian Tax Authority Release and Higher E November 2016

New Features in Primavera P6 16.2

Designing with Oracle Java CAPS Communication Adapters

Oracle Cloud What's New for Oracle WebCenter Portal Cloud Service

Export generates an empty file

Oracle mymicros.net, icare, myinventory and mylabor Self Host Release Notes Release v April 2015

Taleo Enterprise Deep Linking Configuration Guide Release 17

Oracle Utilities Work and Asset Management

Oracle Communications Convergent Charging Controller. Sample Message Flows Reference Guide Release 6.0.1

Microsoft Active Directory Plug-in User s Guide Release

JavaFX. JavaFX Overview Release E

Oracle Cloud E

Materials Control. Installation MC POSWebService. Product Version Joerg Trommeschlaeger. Date: Version No. of Document: 1.

Oracle Simphony Venue Management (SimVen) Installation Guide Release Part Number: E

Oracle Utilities Work and Asset Management

Oracle Enterprise Manager. 1 Introduction. System Monitoring Plug-in for Oracle Enterprise Manager Ops Center Guide 11g Release 1 (

Oracle Utilities Smart Grid Gateway


Oracle WebCenter Portal

Introduction to Auto Service Request

Oracle Fusion Middleware

Managing Personally Identifiable Information in P6 Professional


Spend less on file attachment storage space Reliably back up your data or file attachments Use your OpenAir data in your reporting tools

Oracle Hospitality RES 3700 Server Setup Guide Release 5.5 E May 2016

Oracle Retail MICROS Stores2 Functional Document Malta Taxation Release July 2017

Oracle Health Sciences Information Gateway. 1 Introduction. Security Guide Release 2.0.1

Sun Virtual Desktop Infrastructure. Update Guide for Version 3.1

Oracle Hospitality Simphony Engagement Cloud Service Release Notes Release 2.0 E January 2016

Acme Packet ETC NIU Memory Upgrade Guide. Formerly Net-Net 4500

Oracle Enterprise Manager Ops Center

Oracle Utilities Work and Asset Cloud Service End-User Provisioning Guide

Module Code Entries Utility Oracle FLEXCUBE Universal Banking Release [December] [2016]

Oracle Exadata Healthchecks Plug-in Contents

Oracle Hospitality Cruise Meal Count System Security Guide Release 8.3 E

Oracle Database Mobile Server

Transcription:

JavaFX Oracle JavaFX Applying Transformations in JavaFX Release 2.1 E20471-03 October 2012

JavaFX Applying Transformations in JavaFX, Release 2.1 E20471-03 Copyright 2011, 2012 Oracle and/or its affiliates. All rights reserved. Primary Author: Dmitry Kostovaorv This software and related documentation are provided under a license agreement containing restrictions on use and disclosure and are protected by intellectual property laws. Except as expressly permitted in your license agreement or allowed by law, you may not use, copy, reproduce, translate, broadcast, modify, license, transmit, distribute, exhibit, perform, publish, or display any part, in any form, or by any means. Reverse engineering, disassembly, or decompilation of this software, unless required by law for interoperability, is prohibited. The information contained herein is subject to change without notice and is not warranted to be error-free. If you find any errors, please report them to us in writing. If this is software or related documentation that is delivered to the U.S. Government or anyone licensing it on behalf of the U.S. Government, the following notice is applicable: U.S. GOVERNMENT RIGHTS Programs, software, databases, and related documentation and technical data delivered to U.S. Government customers are "commercial computer software" or "commercial technical data" pursuant to the applicable Federal Acquisition Regulation and agency-specific supplemental regulations. As such, the use, duplication, disclosure, modification, and adaptation shall be subject to the restrictions and license terms set forth in the applicable Government contract, and, to the extent applicable by the terms of the Government contract, the additional rights set forth in FAR 52.227-19, Commercial Computer Software License (December 2007). Oracle America, Inc., 500 Oracle Parkway, Redwood City, CA 94065. This software or hardware is developed for general use in a variety of information management applications. It is not developed or intended for use in any inherently dangerous applications, including applications that may create a risk of personal injury. If you use this software or hardware in dangerous applications, then you shall be responsible to take all appropriate fail-safe, backup, redundancy, and other measures to ensure its safe use. Oracle Corporation and its affiliates disclaim any liability for any damages caused by use of this software or hardware in dangerous applications. Oracle and Java are registered trademarks of Oracle and/or its affiliates. Other names may be trademarks of their respective owners. Intel and Intel Xeon are trademarks or registered trademarks of Intel Corporation. All SPARC trademarks are used under license and are trademarks or registered trademarks of SPARC International, Inc. AMD, Opteron, the AMD logo, and the AMD Opteron logo are trademarks or registered trademarks of Advanced Micro Devices. UNIX is a registered trademark licensed through X/Open Company, Ltd. This software or hardware and documentation may provide access to or information on content, products, and services from third parties. Oracle Corporation and its affiliates are not responsible for and expressly disclaim all warranties of any kind with respect to third-party content, products, and services. Oracle Corporation and its affiliates will not be responsible for any loss, costs, or damages incurred due to your access to or use of third-party content, products, or services.

Contents 1 Translation 2 Rotation 3 Scaling 4 Shearing 5 Multiple Transformations iii

iv

Part I Part I About This Document A transformation changes the place of a graphical object in a coordinate system according to certain parameters. The following types of transformations are supported in JavaFX: n n n Translation Rotation Scaling n Shearing These transformations can be applied to either a standalone node or to groups of nodes. You can apply one transformation at a time or you can combine transformations and apply several transformations to one node. All transformations are located in the javafx.scene.transform package and are subclasses of the Transform class. The Transform class implements the concepts of affine transformations. The Affine class extends the Transform class and acts as a superclass to all transformations. Affine transformations are based on euclidean algebra, and perform a linear mapping (through the use of matrixes) from initial coordinates to other coordinates while preserving the straightness and parallelism of lines. Affine transformations can be constructed using observablearraylists rotations, translations, scales, and shears. Note: Usually, do not use the Affine class directly, but instead, use the specific Translate, Scale, Rotate, or Shear transformations. Transformations in JavaFX can be performed along three coordinates, thus enabling users to create three-dimensional (3-D) objects and effects. To manage the display of objects with depth in 3-D graphics, JavaFX implements z-buffering. Z-buffering ensures that the perspective is the same in the virtual world as it is in the real one: a solid object in the foreground blocks the view of one behind it. Z-buffering can be enabled by using the setdepthtest class. You can try to disable z-buffering (setdepthtest(depthtest.disable) ) in the sample application to see the effect of the z-buffer. To simplify transformation usage, JavaFX implements transformation constructors with the x-axis and y-axis along with the x, y, and z axes. If you want to create a two-dimensional (2-D) effect, you can specify only the x and y coordinates. If you want to create a 3-D effect, specify all three coordinates. To be able to see 3-D objects and transformation effects in JavaFX, users must enable the perspective camera.

Though knowing the underlying concepts can help you use JavaFX more effectively, you can start using transformations by studying the example provided with this document and trying different transformation parameters. For more information about particular classes, methods, or additional features, see the API documentation. In this document, a Xylophone application is used as a sample to illustrate all the available transformations.

1 1Translation The translation transformation shifts a node from one place to another along one of the axes relative to its initial position. The initial position of the xylophone bar is defined by x, y, and z coordinates. In Example 1 1, the initial position values are specified by the xstart, ypos, and zpos variables. Some other variables are added to simplify the calculations when applying different transformations. Each bar of the xylophone is based on one of the base bars. The example then translates the base bars with different shifts along the three axes to correctly locate them in space. Example 1 1 shows a code snippet from the sample application with the translation transformation. Example 1 1 Translation Group rectanglegroup = new Group(); rectanglegroup.setdepthtest(depthtest.enable); double xstart = 260.0; double xoffset = 30.0; double ypos = 300.0; double zpos = 0.0; double barwidth = 22.0; double bardepth = 7.0; // Base1 Cube base1cube = new Cube(1.0, new Color(0.2, 0.12, 0.1, 1.0), 1.0); base1cube.settranslatex(xstart + 135); base1cube.settranslatez(ypos+20.0); base1cube.settranslatey(11.0); Translation 1-1

1-2 Oracle JavaFX Applying Transformations in JavaFX

2 2Rotation The rotation transformation moves the node around a specified pivot point of the scene. You can use the rotate function of the Transform class to perform the rotation. To rotate the camera around the xylophone in the sample application, the rotation transformation is used, although technically, it is the xylophone itself that is moving when the mouse rotates the camera. Example 2 1 shows the code for the rotation transformation. Example 2 1 Rotation class Cam extends Group { Translate t = new Translate(); Translate p = new Translate(); Translate ip = new Translate(); Rotate rx = new Rotate(); { rx.setaxis(rotate.x_axis); } Rotate ry = new Rotate(); { ry.setaxis(rotate.y_axis); } Rotate rz = new Rotate(); { rz.setaxis(rotate.z_axis); } Scale s = new Scale(); public Cam() { super(); gettransforms().addall(t, p, rx, rz, ry, s, ip); } }... scene.setonmousedragged(new EventHandler<MouseEvent>() { public void handle(mouseevent me) { mouseoldx = mouseposx; mouseoldy = mouseposy; mouseposx = me.getx(); mouseposy = me.gety(); mousedeltax = mouseposx - mouseoldx; mousedeltay = mouseposy - mouseoldy; if (me.isaltdown() && me.isshiftdown() && me.isprimarybuttondown()) { cam.rz.setangle(cam.rz.getangle() - mousedeltax); } else if (me.isaltdown() && me.isprimarybuttondown()) { cam.ry.setangle(cam.ry.getangle() - mousedeltax); cam.rx.setangle(cam.rx.getangle() + mousedeltay); } else if (me.isaltdown() && me.issecondarybuttondown()) { double scale = cam.s.getx(); double newscale = scale + mousedeltax*0.01; cam.s.setx(newscale); cam.s.sety(newscale); cam.s.setz(newscale); Rotation 2-1

}); } } else if (me.isaltdown() && me.ismiddlebuttondown()) { cam.t.setx(cam.t.getx() + mousedeltax); cam.t.sety(cam.t.gety() + mousedeltay); } Note that the pivot point and the angle define the destination point the image is moved to. Carefully calculate values when specifying the pivot point. Otherwise, the image might appear where it is not intended to be. For more information, see the API documentation. 2-2 Oracle JavaFX Applying Transformations in JavaFX

3 3Scaling The scaling transformation causes a node to either appear larger or smaller, depending on the scaling factor. Scaling changes the node so that the dimensions along its axes are multiplied by the scale factor. Similar to the rotation transformations, scaling transformations are applied at a pivot point. This pivot point is considered the point around which scaling occurs. To scale, use the Scale class and the scale function of the Transform class. In the Xylophone application, you can scale the xylophone using the mouse while pressing Alt and the right mouse button. The scale transformation is used to see the scaling. Example 3 1 shows the code for the scale transformation. Example 3 1... Scaling else if (me.isaltdown() && me.issecondarybuttondown()) { double scale = cam.s.getx(); double newscale = scale + mousedeltax*0.01; cam.s.setx(newscale); cam.s.sety(newscale); cam.s.setz(newscale); } Scaling 3-1

3-2 Oracle JavaFX Applying Transformations in JavaFX

4 4Shearing A shearing transformation rotates one axis so that the x-axis and y-axis are no longer perpendicular. The coordinates of the node are shifted by the specified multipliers. To shear, use the Shear class or the shear function of the Transform class. In the Xylophone application, you can shear the xylophone by dragging the mouse while holding Shift and pressing the left mouse button. Figure 4 1 Shearing Transformation Example 4 1 shows the code snippet for the shear transformation. Example 4 1 Shearing else if (me.isshiftdown() && me.isprimarybuttondown()) { double yshear = shear.gety(); shear.sety(yshear + mousedeltay/1000.0); double xshear = shear.getx(); shear.setx(xshear + mousedeltax/1000.0); } Shearing 4-1

4-2 Oracle JavaFX Applying Transformations in JavaFX

5 5Multiple Transformations You can construct multiple transformations by specifying an ordered chain of transformations. For example, you can scale an object and then apply a shearing transformation to it, or you can translate an object and then scale it. Example 5 1 shows multiple transformations applied to an object to create a xylophone bar. Example 5 1 Multiple Transformation Cube base1cube = new Cube(1.0, new Color(0.2, 0.12, 0.1, 1.0), 1.0); base1cube.settranslatex(xstart + 135); base1cube.settranslatez(ypos+20.0); base1cube.settranslatey(11.0); base1cube.setscalex(barwidth*11.5); base1cube.setscalez(10.0); base1cube.setscaley(bardepth*2.0); Multiple Transformations 5-1

5-2 Oracle JavaFX Applying Transformations in JavaFX