-
Bug
-
Resolution: Cannot Reproduce
-
P4
-
None
-
8
-
b104
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;
}
}
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;
}
}