2019独角兽企业重金招聘Python工程师标准>>>

我的博文小站:http://www.xby1993.net,文章更新以博文小站为主,一般与oschina同步发布

原创文章,转载请注明出处,作者。

Package javafx.scene

Provides the core set of base classes for the JavaFX Scene Graph API.

See: Description

  • Class Summary

    Class Description
    Camera

    Base class for a camera used to render a scene.

    Cursor

    A class to encapsulate the bitmap representation of the mouse cursor.

    Group

    Group node contains an ObservableList of children that are rendered in order whenever this node is rendered.

    GroupBuilder<B extends GroupBuilder<B>>

    Builder class for javafx.scene.Group

    ImageCursor

    A custom image representation of the mouse cursor.

    ImageCursorBuilder<B extendsImageCursorBuilder<B>>

    Builder class for javafx.scene.ImageCursor

    Node

    Base class for scene graph nodes.

    NodeBuilder<B extends NodeBuilder<B>>

    Builder class for javafx.scene.Node

    ParallelCamera

    Specifies a parallel camera for rendering a scene without perspective correction.

    Parent

    The base class for all nodes that have children in the scene graph.

    ParentBuilder<B extends ParentBuilder<B>>

    Builder class for javafx.scene.Parent

    PerspectiveCamera

    Specifies a perspective camera for rendering a scene.

    PerspectiveCameraBuilder<B extendsPerspectiveCameraBuilder<B>>

    Builder class for javafx.scene.PerspectiveCamera

    Scene

    The JavaFX Scene class is the container for all content in a scene graph.

    SceneAccessor
    SceneBuilder<B extends SceneBuilder<B>>

    Builder class for javafx.scene.Scene

    SnapshotParameters

    Parameters used to specify the rendering attributes for Node snapshot.

    SnapshotParametersBuilder<B extendsSnapshotParametersBuilder<B>>

    Builder class for javafx.scene.SnapshotParameters

    SnapshotResult

    This class holds the result of a snapshot operation.

  • Enum Summary
    Enum Description
    CacheHint

    Cache hints for use with Node.cacheHint

    DepthTest

    This enum defines the possible states for the depthTest flag in node.

主要有Scene顶级容器,Node节点基类,Parent分支节点基类,Group分支节点类,.节点渲染类Camera,鼠标光标类:Cursor,SnapShot类及其参数结果类。同时由于采用建造者模式,故而有对应的Builder类。

Package javafx.scene Description

Provides the core set of base classes for the JavaFX Scene Graph API. A scene graph is a tree-like data structure, where each item in the tree has zero or one parent and zero or more children.

The two primary classes in this package are:

  • Scene – Defines the scene to be rendered. It contains a fill variable(即fill属性,可用setFill()方法进行设置) that specifies the background of the scene, width andheight variables that specify the size of the scene, and a content sequence that contains a list of "root" Nodes to be rendered onto the scene. This sequence of Nodes is the scene graph for this Scene. A Scene is rendered onto a Stage, which is the top-level container for JavaFX content.

  • Node – Abstract base class for all nodes in the scene graph. Each node is either a "leaf" node with no child nodes or a "branch" node with zero or more child nodes. Each node in the tree has zero or one parent. Only a single node within each tree in the scene graph will have no parent, which is often referred to as the "root" node. There may be several trees in the scene graph. Some trees may be part of a Scene, in which case they are eligible to be displayed. Other trees might not be part of anyScene.

Branch nodes are of type Parent or subclasses thereof.

Leaf nodes are classes such as RectangleTextImageViewMediaView, or other such leaf classes which cannot have children.

A node may occur at most once anywhere in the scene graph. Specifically, a node must appear no more than once in the children list of a Parent or as the clip of a Node. See the Node class for more details on these restrictions.

public class Example extends Application {@Override public void start(Stage stage) {Group root = new Group();Scene scene = new Scene(root, 200, 150);scene.setFill(Color.LIGHTGRAY);Circle circle = new Circle(60, 40, 30, Color.GREEN);Text text = new Text(10, 90, "JavaFX Scene");text.setFill(Color.DARKRED);Font font = new Font(20);text.setFont(font);root.getChildren().add(circle);root.getChildren().add(text);stage.setScene(scene);stage.show();}public static void main(String[] args) {Application.launch(args);}
}

1. Node基类

Base class for scene graph nodes. A scene graph is a set of tree data structures

javafx.scene.Node是这个树体系的基类。

继承体系:

  • java.lang.Object

  • javafx.scene.Node

    • Direct Known Subclasses:

    • Canvas, ImageView, MediaView, Parent, Shape

    • All Implemented Interfaces:

    • EventTarget

Each item in the scene graph is called a Node. Branch nodes are of type Parent, whose concrete subclasses are GroupRegion, and Control, or subclasses thereof.

Leaf nodes are classes such as RectangleTextImageViewMediaView, or other such leaf classes which cannot have children.

以下规则是为了防止树体系无限循环交错的规则:

A node may occur at most once anywhere in the scene graph. Specifically, a node must appear no more than once in all of the following: as the root node of a Scene, the children ObservableList of a Parent, or as the clip of a Node.

The scene graph must not have cycles. A cycle would exist if a node is an ancestor of itself in the tree, considering the Group content ObservableList, Parent children ObservableList, and Node clip relationships mentioned above.

If a program adds a child node to a Parent (including Group, Region, etc) and that node is already a child of a different Parent or the root of a Scene, the node is automatically (and silently) removed from its former parent. If a program attempts to modify the scene graph in any other way that violates the above rules, an exception is thrown, the modification attempt is ignored and the scene graph is restored to its previous state.

总之就是一个节点只能在树体系中最多出现一次。不能交错添加节点

关于线程注意事项:Node objects may be constructed and modified on any thread as long they are not yet attached to a Scene. An application must attach nodes to a Scene, and modify nodes that are already attached to a Scene, on the JavaFX Application Thread.


关于节点标识ID:

String ID

Each node in the scene graph can be given a unique id. This id is much like the "id" attribute of an HTML tag in that it is up to the designer and developer to ensure that the id is unique within the scene graph. A convenience function calledlookup(String) can be used to find a node with a unique id within the scene graph, or within a subtree of the scene graph. The id can also be used identify nodes for applying styles; see the CSS section below.


节点变换:

Transformations

Any Node can have transformations applied to it. These include translation, rotation, scaling, or shearing.

translation rotation scaling shearing

边界矩形

Bounding Rectangles

设置变量boundsInLocal  boundsInParent   layoutBounds


节点样式:

CSS

The Node class contains idstyleClass, and style variables that are used in styling this node from CSS. The id and styleClass variables are used in CSS style sheets to identify nodes to which styles should be applied. The style variable contains style properties and values that are applied directly to this node.

For further information about CSS and how to apply CSS styles to nodes, see the CSS Reference Guide.

2 Parent分支节点基类与分支节点Group. Region,Control

Parent:
public abstract class Parent extends Node

The base class for all nodes that have children in the scene graph.

This class handles all hierarchical scene graph operations, including adding/removing child nodes, marking branches dirty for layout and rendering, picking, bounds calculations, and executing the layout pass on each pulse.

There are three direct concrete Parent subclasses

  • Group effects and transforms to be applied to a collection of child nodes.

  • Region class for nodes that can be styled with CSS and layout children.

  • base Control class for high-level skinnable nodes designed for user interaction.(Control节点主要用户可以让用户来操作的节点,如按钮,文本框,可以与用户交互,用户可操作的节点。同时由于Control实现了Skinnable接口,故而可以轻松地设置皮肤,定制外观)


Group(Group一般作为根节点root)

@DefaultProperty(value="children")
public class Groupextends Parent

Group node contains an ObservableList of children that are rendered in order whenever this node is rendered.

Group will take on the collective bounds of its children and is not directly resizable.

Any transform, effect, or state applied to a Group will be applied to all children of that group. Such transforms and effects will NOT be included in this Group's layout bounds, however if transforms and effects are set directly on children of this Group, those will be included in this Group's layout bounds.

By default, a Group will "auto-size" its managed resizable children to their preferred sizes during the layout pass to ensure that Regions and Controls are sized properly as their state changes. If an application needs to disable this auto-sizing behavior, then it should set autoSizeChildren to false and understand that if the preferred size of the children change, they will not automatically resize (so buyer beware!).

Group Example:

import javafx.scene.*;
import javafx.scene.paint.*;
import javafx.scene.shape.*;
import java.lang.Math;Group g = new Group();
for (int i = 0; i < 5; i++) {Rectangle r = new Rectangle();r.setY(i * 20);r.setWidth(100);r.setHeight(10);r.setFill(Color.RED);g.getChildren().add(r);
}



Control:

Class Control相当于Layout布局器

  • java.lang.Object

    • javafx.scene.Parent

    • javafx.scene.control.Control

    • javafx.scene.Node

    • Direct Known Subclasses:

    • Accordion, ChoiceBox, ComboBoxBase, HTMLEditor, Labeled, ListView, MenuBar, Pagination, ProgressIndicator, ScrollBar,ScrollPane, Separator, Slider, SplitPane, TableView, TabPane, TextInputControl, ToolBar, TreeView

    • All Implemented Interfaces:

    • EventTarget, Skinnable


(Control节点主要用户可以让用户来操作的节点,如按钮,文本框,可以与用户交互,用户可操作的节点。同时由于Control实现了Skinnable接口,故而可以轻松地设置皮肤,定制外观)

关于Control节点的焦点转移focusTraversable

Most controls have their focusTraversable property set to true by default, however read-only controls such as Label andProgressIndicator, and some controls that are containers ScrollPane and ToolBar do not. 


Class Region相当于Layout布局器。

  • Direct Known Subclasses:

  • Axis, Chart, Pane

  • Class Region

  • java.lang.Object

    • javafx.scene.Parent

    • javafx.scene.layout.Region

    • javafx.scene.Node

  • public class Regionextends Parent

    A Region is an area of the screen that can contain other nodes and be styled using CSS.

    It can have multiple backgrounds under its contents and multiple borders around its content. By default it's a rectangle with possible rounded corners, depending on borders. It can be made into any shape by specifying the shape. It is designed to support as much of the CSS3 specification for backgrounds and borders as is relevant to JavaFX. The full specification is available at css3-background.

    By default a Region inherits the layout behavior of its superclass, Parent, which means that it will resize any resizable child nodes to their preferred size, but will not reposition them. If an application needs more specific layout behavior, then it should use one of the Region subclasses: StackPaneHBoxVBoxTilePaneFlowPaneBorderPaneGridPane, or AnchorPane.

    To implement more custom layout, a Region subclass must override computePrefWidthcomputePrefHeight, and layoutChildren. Note thatlayoutChildren is called automatically by the scene graph while executing a top-down layout pass and it should not be invoked directly by the region subclass.

    Region subclasses which layout their children will position nodes by setting layoutX/layoutY and do not altertranslateX/translateY, which are reserved for adjustments and animation.

    • Direct Known Subclasses:

    • Axis, Chart, Pane

    • All Implemented Interfaces:

    • EventTarget

javafx.scene.web

Class WebView

  • java.lang.Object

    • javafx.scene.Parent

    • javafx.scene.web.WebView

    • javafx.scene.Node

    • All Implemented Interfaces:

    • EventTarget


extends Parent

WebView is a Node that manages a WebEngine and displays its content. The associated WebEngine is created automatically at construction time and cannot be changed afterwards. WebView handles mouse and some keyboard events, and manages scrolling automatically, so there's no need to put it into a ScrollPane.

WebView objects must be created and accessed solely from the FX thread.

Class ImageCursor

  • java.lang.Object

    • javafx.scene.ImageCursor

    • javafx.scene.Cursor

  • public class ImageCursorextends Cursor

    A custom image representation of the mouse cursor. On platforms that don't support custom cursors, Cursor.DEFAULT will be used in place of the specified ImageCursor.

    Example:

    import javafx.scene.*;
    import javafx.scene.image.*;Image image = new Image("mycursor.png");Scene scene = new Scene(400, 300);
    scene.setCursor(new ImageCursor(image,image.getWidth() / 2,image.getHeight() /2));

Class NodeBuilder<B extends NodeBuilder<B>>

  • java.lang.Object

    • javafx.scene.NodeBuilder<B>

  • @Generated(value="Generated by javafx.builder.processor.BuilderProcessor")
    public abstract class NodeBuilder<B extends NodeBuilder<B>>extends java.lang.Object

    Builder class for javafx.scene.Node

    • Direct Known Subclasses:

    • CanvasBuilder, ImageViewBuilder, MediaViewBuilder, ParentBuilder, ShapeBuilder

转载于:https://my.oschina.net/xby1993/blog/182594

javafx官方文档学习之二Scene体系学习一相关推荐

  1. JavaFX官方文档

    1. JavaFX官方文档:

  2. 百度官方文档Plus版,PaddlePaddle深度学习框架介绍

    作者:木羊同学 来源:华章计算机(hzbook_jsj) 现在深度学习框架不但内卷严重,而且头部效应明显.一提起深度学习框架,首先想到的肯定是Google家的TensorFlow,和Facebook家 ...

  3. jQuery-select2 官方文档笔记(二)——较高级应用

    select2官网:https://select2.org/ 一.Search 1. matcher 2. 分组matcher 3. 设置最短最长搜索词组长度(minimumInputLength & ...

  4. Nginx官方文档(三十二)【ngx_http_slice_module|ngx_http_spdy_module】

    ngx_http_slice_module 示例配置 指令 slice 内嵌变量 ngx_http_slice_module 模块(1.9.8)是一个过滤器,它将请求拆分为子请求,每个子请求都返回一定 ...

  5. Spring官方文档阅读(二)之Bean的简单理解与使用

    1.3.Bean简介 Spring IoC容器管理一个或多个bean,这些bean是使用我们提供给容器的配置元数据创建的(例如,以XML<bean//>定义的形式 ),在容器本身内,这些b ...

  6. spark之4:基础指南(源自官方文档)

    spark之4:基础指南(源自官方文档) @(SPARK)[spark, 大数据] spark之4基础指南源自官方文档 一简介 二接入Spark 三初始化Spark 一使用Shell 四弹性分布式数据 ...

  7. 都在夸官方文档 Vue.js 2021 年度报告出炉!

    整理 | 苏宓 出品 | CSDN(ID:CSDNnews) 作为前端开发框架三剑客之一,Vue 自 2014 年发布以来,成为很多开发者必备的工具. 近日,国外软件开发机构 Monterail 在对 ...

  8. linux3.10.53编译,根据官方文档在Linux下编译安装Apache

    根据官方文档在Linux下编译安装Apache 前言 永远记住官方文档才是最准确的安装手册,这篇文章仅为对官方文档的解读和补充,学习提升务必阅读官方文档: http://httpd.apache.or ...

  9. python pymssql - pymssql模块官方文档的翻译

    译者注:译者博客(http://blog.csdn.net/lin_strong),转载请保留这条.此为pymssql模块version2.1.4官方文档的翻译,仅供学习交流使用,请勿用于商业用途. ...

最新文章

  1. 如何获取iOS设备的IP地址
  2. Raw264.7培养经验分享
  3. POJ 2018 Best Cow Fences (二分答案构造新权值 or 斜率优化)
  4. Servlet使用适配器模式进行增删改查案例(Emp.java)
  5. 查找学生链表c语言,【查找链表面试题】面试问题:C语言实现学生… - 看准网...
  6. 开心的小明 (NYOJ49) [动态规划.01背包]
  7. 以京东为代表电商平台成中华老字号销售增速最快渠道
  8. [RK3399][Android7.1] 调试笔记 --- 查看开机上一次kernel log
  9. 判断在ios系统中打开微信浏览器
  10. 电路布线问题(迷宫问题)
  11. c#高级编程(第八版)-第六章数组随笔
  12. CnOpenData中国上市公司投资者关系管理数据
  13. 命名时取代基优先顺序_求在有机化学的命名中,较优基团的排列顺序在有机化学的命名中,较优基团的排列顺序.急用....
  14. css3中-moz、-ms、-webkit、-o分别代表的意思
  15. ubuntu下无线网卡解决经历
  16. python 将一个正整数分解质因数。例如:输入90,打印出90=2*3*3*5。
  17. 领导合影站位图_领导出席各类活动席位安排(详细附图)
  18. python爬虫入门——13行代码制作英语翻译器教程,小白入门一点通
  19. iperf工具的安装和使用
  20. 微金所案例(轮播+自适应布局)

热门文章

  1. webpack-插件机制杂记
  2. [MySQL Reference Manual] 5 MySQL 服务管理
  3. Lucene核心数据结构——FST存词典,跳表存倒排或者roarning bitmap 见另外一个文章...
  4. tomcat用80port能够启动,可是浏览器不显示tomcat首页
  5. 【C#】第3章学习要点(三)--常用类和结构的用法
  6. 在Fragment中实现百度地图,定位到当前位置(基于SDKv2.1.0)
  7. RotateAnimation详解
  8. 利用List比较数组有优势吗?
  9. 简单客户端服务器模型(C++、python和go语言示例)
  10. centos源码安装mysql5.7.25-boost