Javafx -- (Article 1: Introduction)

Source: Internet
Author: User
What is javafx?

The javafx platform is a rich client platform solution that allows application developers to easily create cross-platform rich client applications. Built on the basis of Java technology, the javafx platform provides a rich set of graphics and media APIs and high-performance hardware-accelerated graphics and media engines to simplify the development of data-driven enterprise client applications.

Javafx has the following advantages:

  • Because the javafx platform is written in Java, Java developers can use existing skills and tools to develop javafx applications.
  • Because Java is widely used, it is easy to find developers who can easily turn javafx applications into products.
  • Because Java technology uses the same server and client platform, it reduces the risks caused by application enterprise solutions.
  • Because of the above advantages, the development cost will also be reduced.
  • Javafx provides developers with a development framework and runtime environment for creating cross-platform enterprise-level business applications.
Architecture and framework of javafx

The javafx platform is a cross-platform application built on Java technology and easy to create and deploy rich client platforms.

Describes the overall architecture of javafx 2, and describes how each part is associated with each other. You can run your javafx code based on the following javafx API. It includes javafx's high-performance graphics engine called Prism; a small and efficient window system called glass; a media engine and a web engine. Although these components are not public, their instructions can help you better understand how to run a javafx application.

Figure 1. Overall architecture of javafx 2

Scenario Diagram

The javafx scenario diagram is displayed at the top of the overall framework and is the starting point of the overall javafx application. It is a hierarchical tree structure node that represents the visualization elements of the application user interface. It can process input and render output.

A single element in a scenario is called a node. Each node has an ID, style class, and boundary value. Except the root node, each node has a parent node and has 0 to multiple subnodes. It can also have the following attributes:

  • Effects, such as blur and shadow
  • Transparency
  • Transform Parameters
  • Event Processing (for example, mouse, keyboard, and input)
  • Specific Application Status

Unlike swing and AWT, javafx scene graphs include la S, images, and media, such as Rectangles and texts.

In most applications, many easy-to-use components are used in the scenario diagram.

javafx.sceneAPIS describe many types of components, such:

  • Nodes: Includes shapes (2-D and 3-D), images, media, embedded web browser, text, UI controls, charts, groups, and containers
  • State: Transforms (positioning and orientation of nodes), visual effects, and other visual state of the content
  • Effects: Simple objects that change the appearance of Scene Graph nodes, such as blurs, shadows, and color adjustment

Java APIs for javafx features

Javafx 2 has a complete set of public APIs displayed at the top layer. These APIs allow you to create Ria applications flexibly. The javafx platform combines the best features and integrations of the Java platform, and immersive media functions are transformed into an intuitive and comprehensive one-stop development environment. These new Java API features include:

  • Powerful Java features such as generics, annotations, and multithreading are allowed.
  • It facilitates web developers to use javafx from other popular dynamic languages such as jruby, groovy and JavaScript.
  • Allow Java developers to use other system languages, such as groovy, to write large or complex javafx applications.
  • Binding is allowed in a language similar to javafx. This includes support for high-performance lazy binding, binding expressions, binding sequence expressions, and local binding. The selected language (such as groovy) can be used to introduce the binding syntax similar to the javafx script.
  • The Java collections library is extended to include the list and map libraries. Based on the changes in the set content, the interface is displayed in time to monitor the changes of its objects.

Javafx 2 is backward compatible with javafx 1.x. Most APIs are compatible, and some APIs, such as layout and media, have also been greatly improved. Javafx 2 supports more web standards, such as CSS styles. More standards will be supported later.

Graphics System

The Graphic System of javafx 2 is the blue part in figure 1, which is the specific implementation of the javafx scenario diagram. It includes 2-D and 3-D scenarios. It provides software optimization for hardware rendering.

Implementation of graph acceleration on the javafx 2 platform:

  • Prism: process rendering. It can run hardware and software rendering including 3-D. Ability to render javafx scenarios. Multiple paths are available for the Agency:
    DirectX 9 on Windows XP and Windows Vista
    DirectX 11 on Windows 7
    OpenGL in MAC, Linux, embedded
    Hardware acceleration for java2d is impossible.
    It is possible to use a path with Full Hardware acceleration, but when it is not effective, use the java2d rendering path, because the java2d rendering path has been distributed across all Java runtime environments (JRE ). This is especially important when processing 3 D scenarios. However, it is used for hardware rendering paths with better performance.
  • Quantum Toolkit: binds prism and Windows tools so that they can be used for javafx. It is also responsible for thread-related rules and event processing.

Glass wing Toolkit

In the middle of Figure 1, the glass drawing wing toolkit provides local operation services, such as management windows, timers, and appearances. It provides services to connect to the javafx platform and local operating systems.

The glass Toolkit can also process event queues. Unlike AWT, it not only manages its own event queue, but also local operating system events. Unlike AWT, the glass toolkit runs a javafx thread while AWT runs a thread and Java runs a thread. This method solves many problems.

Threads

The following threads run after the system is started, including:

  • Javafx Application Thread: This is the main thread of the javafx application.
  • Prism render thread: This thread processes each other through its own event distribution program. Used to render event distribution.
  • Media thread: This program runs in the background and uses the javafx application thread through the final frame.

Pulse

A pulse is an event that indicates the status of the scene chart changes over time. A pulse runs 60 frames per second. Even if the scene animation does not change the pulse, it may also change. For example, when the position of a button changes, the pulse is changed.

When a pulse is triggered, the corresponding changes will also be synchronized to the rendering layer. Pulse enables application developers to process asynchronous events. This important attribute allows the system to execute events in batches on the pulse.

Layout and CSS also have pulse events. Many changes on the scene map will lead to changes in layout and CSS. The system will automatically optimize the performance through pulse. Application developers can manually trigger the layout as needed.

The glass wing toolkit is used to execute the pulse event.

Media and Images

The media function of javafx can bejavafx.scene.mediaIs used effectively. Provides processing of MP3, AIFF, FLV, and other files. Javafx media provides three components: a media object acts as a media file, a media player plays a media file, and mediaview acts as a node to display media files.

The media engine component is displayed in the green part of Figure 1. It is re-designed in javafx 2, improved in performance, and extended.

Embedded browser

The built-in browser of javafx is a new user interface of javafx. It provides the full web browsing function through this API. The orange part shown in Figure 1 is based on WebKit. This open-source browser engine supports HTML 5, CSS, JavaScript, Dom, and SVG. It can develop the following features in Java applications:

  • Rendering HTML content from a local or remote URL
  • Supports historical browsing and provides rollback and Forward Navigation
  • Reload content
  • Application Effects of Web Components
  • Edit HTML content
  • Execute JavaScript commands
  • Event handling

The content browser consists of the following classes:

  • The web engine provides basic web browsing functions.
  • A web engine webview encapsulates HTML content into an application scenario, and provides application effects and conversion of fields and methods. This is an extended node class.

CSS

Javafx stacked style sheet (CSS) provides a javafx application that customizes the style application capability, without changing the source code of any application. CSS can be applied to any node in the javafx scenario diagram and to asynchronous nodes. The CSS style of javafx can also be easily allocated to the running scenario, so that the application's appearance can be dynamically changed.

That is, two examples with two different styles applied but the components are the same.

Figure 2

Javafx CSS is based on W3C CSS 2.1 specifications and supports some CSS 3 functions. CSS support and extensions of javafx have been designed to allow the CSS style sheets of javafx to be parsed cleanly through any compatible CSS parser, or even not support javafx extensions. This makes the mixed CSS style javafx and other purposes (such as HTML pages) into a single style table. All javafx attribute names plus the prefix of the vendor-extended "Fx-", including those html css that may seem to comply with the standard, because some javafx values have slightly different semantics.

Ui controls


They can make full use of the rich visual features of the javafx platform, can be on different platforms. Javafx CSS allows theme and skin UI controls.

Figure 3 lists some of the components that can be used.javafx.scene.control.

Figure 3

Layout


Similar to other common la S.

Deployment


Javafx has three deployment methods:

Run it separately: you can install it locally and double-click it to run it. In this way, users can access the service in a non-Online manner.

Browser: in this way, javafx is embedded into a web page for automatic loading. It can interact with elements on the page through the page JavaScript.

Web startup: This method requires first download. Once the download is complete, the user can start the JNLP file downloaded by the application.

Key features

It has the following features:

  • Fully integrated with jdk7.
  • Provides similar syntax features as Java APIs.
  • New Image Processing Engine.
  • Fxml, a language based on XML to define javafx applications.
  • A new media engine that supports playing webpages with multimedia content.
  • Web capability expansion.
  • Various built-in UI controls, including charts, tables, menus, and panes.
  • It is very easy to package through the methods described above.
  • Cross-platform.
  • The same API format as Java APIs.
How to Create a javafx Application
  1. Download the latest JDK version and support javafx.
  2. Install and configure the application. Follow the Wizard to create a simple application.
  3. Download the javafx scene builder and compile and run it.
Use javafx scene Builder

Download javafx scene builder.

Note:

The javafx scenario builder does not depend on any specific IDE. You can run it as an independent tool to create your UI layout and edit the result fxml file using a text editor for your selection. If you choose to use netbeans ide outside of this tutorial, some of them emphasize what needs to be done to connect to the layout in this tutorial. You can build the Java source code and application style sheet of the sample application, run the sample application using the Apache ant utility.

Javafx scene builder operation interface.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.