I have a javaFX 8 application that works fine in jre 1.8.0_45, but today a user came to me with a problem. After some investigation, I realized that this was due to its recent release of jre, in particular 1,8,0_60. I read the GIS shapefile and drew several paths to the group (for example, 30,000 or more) in my version, it was a little slower, but it worked fine. In the latest version, the image turned out to be distorted. Paths that go out of place and fail in pieces.
correct image generated in jre 1.8.0_45
distorted image generated in jre 1.8.0_60
So, I decided to make a small test application to separate the problem from everything that I could do. At the same time, I learned that the problem is not only in drawing outlines in a group, but also in drawing on canvas. Also, if I manage to redraw the screen, the image will look normal. For example, I have a checkbox associated with the visible property of the group containing the paths, so if I set it to false and then true, it takes some time to draw a scene, but then it looks fine. The test application is very simple, if you click the button, you create a canvas with some 10px10p squares, if you click another, you will create more squares and thus the display will fail.
package gisUI; import javafx.application.Application; import javafx.application.Platform; import javafx.scene.Group; import javafx.scene.Node; import javafx.scene.Scene; import javafx.scene.canvas.Canvas; import javafx.scene.canvas.GraphicsContext; import javafx.scene.control.Button; import javafx.scene.layout.HBox; import javafx.scene.layout.Pane; import javafx.scene.layout.VBox; import javafx.scene.paint.Color; import javafx.scene.paint.Paint; import javafx.scene.shape.LineTo; import javafx.scene.shape.MoveTo; import javafx.scene.shape.Path; import javafx.stage.Stage; public class Path2DTestApplication extends Application { private static final int WIDTH = 10; Group content = new Group(); @Override public void start(Stage stage) throws Exception { stage.setTitle("JavaFX 1.8.0_60 rendering test"); Button button = new Button("Canvas 100 x 30"); button.setOnAction(a->doGenerateCanvas(100,30)); Button button2 = new Button("Canvas 100 x 400"); button2.setOnAction(a->doGenerateCanvas(100,400)); Button button3 = new Button("Paths 100 x 30"); button3.setOnAction(a->doGeneratePaths(100,30)); VBox vBox = new VBox(); vBox.getChildren().addAll(new HBox(button,button2,button3),content); Group root = new Group(); root.getChildren().add(vBox); Scene scene = new Scene(root,80*WIDTH,60*WIDTH);
Test 1: press the "Canvas 100 x 30" button, 3000 squares are typed correctly and quickly
Test 2: click the “Canvas 100 x 400” button, 40,000 squares showing the failure are shown.
Test 3: click the “Canvas 100 x 400” button, 40,000 squares are drawn correctly and quickly.
Test 4: click the "100 x 30 Ways" button, 3000 squares are displayed showing the glitch.
Test 5: press the “100 x 30 Ways” button again, 3000 squares are typed.
This is my first question for stakoverflow, sorry if I was not clear enough.
If anyone knows if this is a jre bug or there are some problems with my code, I would be grateful. Any workarounds would also be helpful. Tks !!