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

Gradient differs between sw and d3d

    Details

    • Type: Bug
    • Status: Resolved
    • Priority: P4
    • Resolution: Cannot Reproduce
    • Affects Version/s: 8
    • Fix Version/s: None
    • Component/s: javafx
    • Environment:

      b104

      Description

      import javafx.application.Application;
      import javafx.stage.Stage;
      import javafx.scene.Scene;
      import javafx.scene.shape.*;
      import javafx.scene.paint.*;
      import javafx.collections.ObservableList;
      import javafx.scene.Group;

      import static javafx.collections.FXCollections.*;

      public class GradientApp extends Application {

          static {
              System.setProperty("prism.order", "sw");
          }

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

          @Override
          public void start(Stage stage) {
              double h =300;
              double w = 400;
              double space = 10.0;
              ObservableList<Double> XYparams = getXYparams(1, 1, w, h, space);
              double z = XYparams.get(0);
              double sX = XYparams.get(1);
              double sY = XYparams.get(2);
              Rectangle firstRectangle = new Rectangle(sX, sY, z, z);
              Stop[] stops = {new Stop(0.0, Color.RED), new Stop(0.5, Color.web("0x0000FF", 0.25F)), new Stop(1.0, Color.YELLOW)};
              firstRectangle.setFill(new RadialGradient((180/Math.PI)*Math.atan2(1.0, 1.0), 0.0, 0.5, 0.5, 0.5, true, CycleMethod.NO_CYCLE, stops));
              Scene scene = new Scene(new Group(), w, h);
              ((Group) scene.getRoot()).getChildren().clear();
              ((Group) scene.getRoot()).getChildren().addAll(firstRectangle);
              stage.setScene(scene);
              firstRectangle.requestFocus();
              stage.show();

              Rectangle secondRectangle = new Rectangle(sX, sY, z, z);
              secondRectangle.setFill(new LinearGradient(0.0, 0.0, 1.0, 0.0, true, CycleMethod.NO_CYCLE, stops));
              Stage secondStage = new Stage();
              Scene secondScene = new Scene(new Group(), w, h);
              ((Group) secondScene.getRoot()).getChildren().clear();
              ((Group) secondScene.getRoot()).getChildren().addAll(secondRectangle);
              secondStage.setScene(secondScene);
              secondStage.setX(0);
              secondStage.show();
          }

          public ObservableList<Double> getXYparams(double kX, double kY, double w, double h, double space) {
              /*
               * The Node is a square
               * result [0] - z width/height of Node
               * result [1] - space between Nodes in X
               * result [2] - space between Nodes in Y
               * result [3] - number of Nodes in X
               * result [4] - number of Nodes in Y
               * result [5] - width of the Stage
               * result [6] - height of the Stage
               */
              ObservableList<Double> result = observableArrayList(0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0);
              result.set(3, kX);
              result.set(4, kY);
              result.set(5, w);
              result.set(6, h);
              double zX = (w - (kX + 1) * space) / kX;
              double zY = (h - (kY + 1) * space) / kY;
              double z = zX;
              if (zX > zY) {
                  z = zY;
              }
              double spaceX = (w - z * kX) / (kX + 1);
              double spaceY = (h - z * kY) / (kY + 1);
              result.set(1, spaceX);
              result.set(2, spaceY);
              result.set(0, z);
              return result;
          }
      }

        Attachments

          Activity

            People

            • Assignee:
              ckyang Chien Yang (Inactive)
              Reporter:
              dzinkevi Dmitry Zinkevich (Inactive)
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:
                Imported: