Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8089221

[Region] Stroked shapes rendered differently starting with 8u40

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Won't Fix
    • Icon: P3 P3
    • None
    • 8u40, 9
    • javafx
    • Windows 7 64-bit
      Java 8u25 and 8u40

      I've noticed some rendering differences between 8u25 and 8u40. I'm not certain if they are bugs or just fixes and I was expecting the buggy behaviour.
      For example, after coloring in the background on the SVG curved edge at the button corner of my widget I can better understand the artifacting I see only with 8u40.

      Here's the test app:

      package renderissues;

      import javafx.application.Application;
      import javafx.scene.Group;
      import javafx.scene.Scene;
      import javafx.scene.control.Label;
      import javafx.scene.control.Slider;
      import javafx.scene.layout.BorderPane;
      import javafx.scene.layout.HBox;
      import javafx.scene.layout.Region;
      import javafx.scene.layout.StackPane;
      import javafx.scene.shape.Circle;
      import javafx.scene.shape.LineTo;
      import javafx.scene.shape.MoveTo;
      import javafx.scene.shape.Path;
      import javafx.scene.shape.PathElement;
      import javafx.scene.transform.Transform;
      import javafx.stage.Stage;

      public class RenderIssues extends Application {

          @Override
          public void start(Stage primaryStage) {
              Region cornerBackground = new Region(); // shape defined in CSS
              cornerBackground.setStyle("-fx-background-color: YELLOW;" +
                  "-fx-position-shape: false;" +
                  "-fx-scale-shape: false;" +
                  "-fx-shape: \"m37,26.65l0,-15.20 c0,-5.21335 -4.48,-9.44446 -10,-9.44446 l-27,0 l0,26.55 c0,7 1.5,7.6 12,7.5 l24,0 l10,0 c-5.49,0 -9.94,-4.17447 -9,-9.35001 z\";" +
                  "-fx-translate-x: 1;" +
                  "-fx-translate-y: -4;" +
                  "-fx-padding: 0;");

              Region cornerBorder = new Region(); // shape defined in CSS
              cornerBorder.setStyle("-fx-background-color: PINK;" +
                  "-fx-border-color: BLACK;\n" +
                  "-fx-position-shape: false; " +
                  "-fx-scale-shape: false; " +
                  "-fx-shape: \"M0,0h26c6.07,0,11,4.93,11,11 v16C37.05,32,41,35,46,35\"; " +
                  "-fx-translate-x: 1; " +
                  "-fx-translate-y: -2.5; " +
                  "-fx-padding: 0;");

              Circle cornerButton = new Circle();
      cornerButton.setRadius(16);

              StackPane cornerSP = new StackPane();
              cornerSP.getChildren().addAll(cornerBackground, cornerBorder, cornerButton);

              BorderPane box = new BorderPane();
              box.setStyle("-fx-border-color: rgb(0,0,0), linear-gradient(rgb(140,140,140) 0%, rgb(80,80,80) 5%, rgb(140,140,140) 10%, rgb(80,80,80) 90%, rgb(140,140,140) 100%);" +
                  "-fx-border-width: 5,2;" +
                  "-fx-border-radius: 8,9;" +
                  "-fx-border-insets: -2 10 4 10, -1 11 5 11;" +
                  "-fx-background-color: GREEN;" +
                  "-fx-background-radius: 7;" +
                  "-fx-background-insets: 2 11 6 11;" +
                  "-fx-padding: 0 -2 0 -1;");
              HBox titleBar = new HBox();
              titleBar.setStyle("-fx-background-radius: 7 7 0 0;" +
                  "-fx-background-insets: 0 0 1 0;" +
                  "-fx-background-color: linear-gradient(to bottom, black, rgba(255,255,255,0));" +
                  "-fx-border-color: componentBorderColor;" +
                  "-fx-border-width: 0 0 1 0;");
              box.setTop(titleBar);
              Label title = new Label("This renders differently in 8u20 and 8u40");
              title.setStyle("-fx-text-fill: WHITE;");
              titleBar.getChildren().add(title);

              Region arrowhead = new Region();
              arrowhead.setStyle("-fx-position-shape: false;" +
                  "-fx-scale-shape: false;" +
                  "-fx-shape: \"M0,0L8,3L8-3z\";" +
                  "-fx-border-color: LIGHTBLUE;" +
                  "-fx-border-width: 2;" +
                  "-fx-border-insets: -1;" +
                  "-fx-background-color: LIGHTBLUE;");
              Path line = new Path();
              line.setStyle("-fx-stroke: LIGHTBLUE;" +
                  "-fx-stroke-width: 2.25;" +
                  "-fx-stroke-line-cap: round;");
              double eX = 50;
              double eY = 0;
              PathElement start = new MoveTo(0, 0);
              PathElement end = new LineTo(eX, eY);
              line.getElements().addAll(start,end);
              arrowhead.getTransforms().add(Transform.rotate(180, 0, 0));
              arrowhead.setLayoutX(eX);
              arrowhead.setLayoutY(eY);
              Group pathGroup = new Group(line, arrowhead);
              box.setCenter(pathGroup);
              HBox bottom = new HBox(cornerSP);
              box.setBottom(bottom);
              Group content = new Group(box);
              BorderPane bp = new BorderPane(content);
              Slider zoomer = new Slider(1, 10, 3);
              box.scaleXProperty().bind(zoomer.valueProperty());
              box.scaleYProperty().bind(zoomer.valueProperty());
              bp.setTop(zoomer);
              Scene scene = new Scene(bp, 700, 250);
              primaryStage.setTitle("Render Issues");
              primaryStage.setScene(scene);
              primaryStage.show();
          }

          public static void main(String[] args) { launch(args); }
      }

        1. 8u20_svg.png
          8u20_svg.png
          1 kB
        2. 8u40_border_bad.png
          8u40_border_bad.png
          17 kB
        3. 8u40_border_good.png
          8u40_border_good.png
          19 kB
        4. 8u40_svg.png
          8u40_svg.png
          1 kB
        5. RenderIssues2.java
          4 kB
        6. RenderIssues2_8u45.png
          RenderIssues2_8u45.png
          40 kB
        7. RenderIssues2_8u60+8089063.png
          RenderIssues2_8u60+8089063.png
          40 kB
        8. RenderIssues_8u31.png
          RenderIssues_8u31.png
          37 kB
        9. RenderIssues_8u45.png
          RenderIssues_8u45.png
          40 kB

            kcr Kevin Rushforth
            swpalmer Scott Palmer
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported: