Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/391.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/http/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
jre 1.8.060中的javafx呈现故障_Java_Rendering_Javafx 8 - Fatal编程技术网

jre 1.8.060中的javafx呈现故障

jre 1.8.060中的javafx呈现故障,java,rendering,javafx-8,Java,Rendering,Javafx 8,我有一个JavaFX8应用程序,它在jre 1.8.045中运行得非常好,但是今天一个用户向我提出了一个问题。经过一些调查,我意识到这与他最近发布的jre有关,特别是1.8.060。 我正在阅读一个GIS形状文件,并在我的版本中绘制了一组(比如30000或更多)的路径。虽然速度有点慢,但效果很好。在最新版本中,图像出现了扭曲。在块中绘制出不合适和不合适比例的路径 所以我决定做一个小的测试应用程序,把这个问题和我可能正在做的任何事情分开。在这样做的过程中,我发现问题不仅在于在组上绘制路径,还在

我有一个JavaFX8应用程序,它在jre 1.8.045中运行得非常好,但是今天一个用户向我提出了一个问题。经过一些调查,我意识到这与他最近发布的jre有关,特别是1.8.060。 我正在阅读一个GIS形状文件,并在我的版本中绘制了一组(比如30000或更多)的路径。虽然速度有点慢,但效果很好。在最新版本中,图像出现了扭曲。在块中绘制出不合适和不合适比例的路径

所以我决定做一个小的测试应用程序,把这个问题和我可能正在做的任何事情分开。在这样做的过程中,我发现问题不仅在于在组上绘制路径,还在于绘制画布。此外,如果我设法重新绘制屏幕的图像将出现罚款。例如,我有一个与包含路径的组的visible属性绑定的复选框,因此如果我将其设置为false,然后设置为true,则需要一些时间来绘制场景,但随后它看起来很好。该测试应用程序非常简单,如果你按下一个按钮,你会生成一个画布,其中一些方块是10px10p,如果你按下另一个按钮,你会生成更多的方块,因此会出现渲染故障

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);//, 1500, 800);//, Color.White);
        stage.setScene(scene);
        stage.show();
    }

    private void doGeneratePaths(int maxX,int maxY) {
        Pane paths = new Pane();
        content.getChildren().clear();
        Platform.runLater(()->{
        for(int i = 0;i<maxX;i++){
            for(int j=0;j<maxY;j++){
                paths.getChildren().add(getPath(i,j));
            }
        }   

        content.getChildren().add(paths);
        });
    }

    private void doGenerateCanvas(int maxX,int maxY) {  
        content.getChildren().clear();
        Platform.runLater(()->{
        Canvas canvas = new Canvas(maxX*WIDTH, maxY*WIDTH);
        GraphicsContext gc = canvas.getGraphicsContext2D();
        int counter =0;
        for(int i = 0;i<maxX;i++){
            for(int j=0;j<maxY;j++){
                gc.setFill(Color. rgb(255,(int) (Math.random()*255),191));
                double[] xCoords = new double[]{i*WIDTH, (i+1)*WIDTH, (i+1)*WIDTH, i*WIDTH};
                double[] yCoords = new double[]{j*WIDTH,(j)*WIDTH,(j+1)*WIDTH,(j+1)*WIDTH};
                gc.fillPolygon(xCoords,yCoords,xCoords.length);
                counter++;
            }
        }   
        System.out.println(counter +" polygons added");
        content.getChildren().add(canvas);
        });
    }

    protected Node getPath(int i,int j) {           
        Path path = new Path();     
        path.getElements().add(new MoveTo(i*WIDTH, j*WIDTH)); 
        path.getElements().add(new LineTo((i+1)*WIDTH, j*WIDTH)); 
        path.getElements().add(new LineTo((i+1)*WIDTH, (j+1)*WIDTH)); 
        path.getElements().add(new LineTo(i*WIDTH, (j+1)*WIDTH)); 
        path.getElements().add(new LineTo(i*WIDTH, j*WIDTH));

        Paint currentColor =Color. rgb(255,(int) (Math.random()*255),191);

        path.setFill(currentColor);
        path.setStrokeWidth(0.1);
        return path;
    }
    public static void main(String[] args) {
        Application.launch(Path2DTestApplication.class, args);
    }
}
package-gisUI;
导入javafx.application.application;
导入javafx.application.Platform;
导入javafx.scene.Group;
导入javafx.scene.Node;
导入javafx.scene.scene;
导入javafx.scene.canvas.canvas;
导入javafx.scene.canvas.GraphicsContext;
导入javafx.scene.control.Button;
导入javafx.scene.layout.HBox;
导入javafx.scene.layout.Pane;
导入javafx.scene.layout.VBox;
导入javafx.scene.paint.Color;
导入javafx.scene.paint.paint;
导入javafx.scene.shape.LineTo;
导入javafx.scene.shape.MoveTo;
导入javafx.scene.shape.Path;
导入javafx.stage.stage;
公共类Path2DTestApplication扩展了应用程序{
专用静态最终整数宽度=10;
组内容=新组();
@凌驾
public void start(Stage)引发异常{
stage.setTitle(“JavaFX1.8.060渲染测试”);
按钮按钮=新按钮(“画布100 x 30”);
按钮设置动作(a->doGenerateCanvas(100,30));
按钮2=新按钮(“画布100 x 400”);
按钮2.设置操作(a->doGenerateCanvas(100400));
按钮按钮3=新按钮(“路径100 x 30”);
按钮3.设置动作(a->DoGeneratePath(100,30));
VBox VBox=新的VBox();
vBox.getChildren().addAll(新的HBox(按钮、按钮2、按钮3)、内容);
组根=新组();
root.getChildren().add(vBox);
场景=新场景(根,80*宽,60*宽);/,1500800);/,颜色.白色);
舞台场景;
stage.show();
}
私有void dogeneratePath(int-maxX,int-maxY){
窗格路径=新建窗格();
content.getChildren().clear();
Platform.runLater(()->{

对于(int i=0;i我在我的MacBook Pro(OS X 10.9.5)上玩过这个。它有一个2880x1800的本机视网膜LCD显示器,还有一个2560x1440的Thunderbolt LCD显示器。请注意,这两个显示器的本机像素分辨率不同

当我运行发布的代码时,我对任何画布渲染都没有问题。当第一次渲染“路径”选项时,或者从“画布”切换到“路径”时,我看到了与您描述的类似的渲染问题,但仅当应用程序显示在thunderbolt显示屏上时才出现。当移动到视网膜显示屏时,一切正常

因此,问题似乎与硬件有关。这显然是一个bug,您应该按照注释中所述报告它,但作为一种解决方法,您可以从命令行使用系统属性
-Dprism.order=sw
切换到软件渲染:

java -Dprism.order=sw gisUI.Path2DTestApplication

这删除了我的系统上的所有渲染错误。您应该知道这可能会影响性能。

这是完整应用程序日志a的github存储库。我在带有Retina display和8u60的MacBook Pro上看不到任何问题。在我的设置中(与@mipa描述的相同),我只在按下“路径”时看到问题在画布显示后。嗯,我看不出“路径”有任何问题,除非你的意思是小正方形在这里有一个小边框,但这是设计的,不是问题。