In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article focuses on "how to render graphics on JavaFX scenes". Interested friends may wish to have a look at it. The method introduced in this paper is simple, fast and practical. Let's let the editor take you to learn how to render graphics on JavaFX scenes.
In order to render graphics on a JavaFX scene, we need basic shapes and colors.
Class is the basic base class for all JavaFX scene graphics nodes. It provides the ability to convert, translate and apply effects to any node.
A class is a descendant of a class.
All older JavaFX 2.x Builder classes have been deprecated in JavaFX 8.
When drawing on a JavaFX scene graph, render lines using screen coordinate space (system).
The screen coordinate system places (0J0) in the upper-left corner.
The x coordinate moves the point along the x axis. When you move the point from top to bottom, the y coordinate value increases.
The following figure shows the screen coordinate system on the right.
In JavaFX, scene graphics objects, such as lines, circles, and rectangles, are derived from classes.
All shape objects can perform geometric operations between two forming regions, such as subtraction, intersection, and union.
To draw lines in JavaFX, we will use classes.
To create an object, we need to specify a start coordinate and an end coordinate.
When you create a line node, there are two ways to set the start and end points.
The first method uses the data type of all parameters of the constructor with parameters startX,startY,endX and endY.
The following code uses the constructor to create a line with a start point (100 focus 10) and an end point (10110).
Line line= Line (100,10,10,110)
The second way to create a row node is to instantiate the class with an empty constructor and then set each property using the setter method.
The following code shows how to create a line object and set the start and end of a row using the setter method.
Line line= Line ()
Line.setStartX (100)
Line.setStartY (10)
Line.setEndX (10)
Line.setEndY (110C)
The line nodes drawn on the scene graph default to a stroke width of 1.0 and a black stroke color.
The stroke color of all shapes is null, which means that there is no color except for the Line,Polyline and Path nodes.
To create different kinds of lines, we can set properties that inherit from the parent class.
The following table shows the properties that we can set on one line.
To retrieve or modify each property, you will use its appropriate getter and setter methods.
The following code creates a Line object and uses the setter method to set the start and end coordinates.
Javafx.application.Application
Javafx.scene.Scene
Javafx.scene.layout.VBox
Javafx.scene.shape.Line
Javafx.stage.Stage
Main Application {
@ Override
Start (Stage stage) {
VBox box= VBox ()
Scene scene= Scene (box,300, 250)
Scene.setFill (null)
Line line= Line ()
Line.setStartX (0.0f)
Line.setStartY (0.0f)
Line.setEndX (100.0f)
Line.setEndY (100.0f)
Box.getChildren (). Add (line)
Stage.setScene (scene)
Stage.show ()
}
Main (String [] args) {
Launch (args)
}
}
At this point, I believe you have a deeper understanding of "how to render graphics on JavaFX scenes". You might as well do it in practice. Here is the website, more related content can enter the relevant channels to inquire, follow us, continue to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.