/*
  * we need screen only because BaseShaderContext requres Screen in the constructor
  */
 private static Screen getScreenForAdapter(List<Screen> screens, int adapterOrdinal) {
   for (Screen screen : screens) {
     if (screen.getAdapterOrdinal() == adapterOrdinal) {
       return screen;
     }
   }
   return Screen.getMainScreen();
 }
  @Override
  public void afterExecute(Runnable r, Throwable t) {
    super.afterExecute(r, t);

    /*
     * clean up what we can after every render job
     *
     * we should really be keeping RenderJob/Scene pools
     */
    if (usePurgatory) {
      Screen screen = Screen.getMainScreen();
      Renderer renderer = Renderer.getRenderer(PrFilterContext.getInstance(screen));
      renderer.releasePurgatory();
    }
  }
Beispiel #3
0
 @Override
 public void start(Stage stage) throws Exception {
   if (headless) {
     System.setProperty("headless.geometry", width + "x" + height);
     NativePlatform platform = NativePlatformFactory.getNativePlatform();
     Field field = NativePlatform.class.getDeclaredField("screen");
     field.setAccessible(true);
     field.set(platform, null);
     Screen.notifySettingsChanged();
   }
   if (stage == null) {
     stage = new Stage();
   }
   Platform.setImplicitExit(false);
   WebView view = new WebView();
   view.setCache(false);
   StackPane root = new StackPane();
   root.setCache(false);
   if (headless) {
     stage.initStyle(StageStyle.UNDECORATED);
   }
   WebEngine engine = view.getEngine();
   engine.getHistory().setMaxSize(HISTORY_SIZE);
   engine.setUserAgent(Long.toString(settingsId));
   Accessor.getPageFor(engine).setDeveloperExtrasEnabled(false);
   Accessor.getPageFor(engine).setUsePageCache(false);
   root.getChildren().add(view);
   stage.setScene(new Scene(root, width, height));
   stage.sizeToScene();
   engine.titleProperty().addListener(new TitleListener(stage));
   stage.show();
   synchronized (lock) {
     myStage = stage;
     myView = view;
     lock.notifyAll();
   }
 }
/**
 * Dialog to edit details of a person.
 *
 * @author Marco Jakob
 */
public class PersonEditDialogController {
  /** param ceiling el efecto onda sobre la imagen */
  private Ellipse ceiling;

  @FXML private ImageView imageViewEinstein;
  private ImageView ceiling_image;
  @FXML private TextField firstNameField;
  @FXML private TextField lastNameField;
  @FXML private TextField streetField;
  @FXML private TextField postalCodeField;
  @FXML private TextField cityField;
  @FXML private DatePicker birthdayField;

  @FXML private BorderPane mainBorderPane;

  private static double TAMANO_PANTALLA = Screen.getMainScreen().getHeight();
  private Stage dialogStage;
  private Person person;
  private boolean okClicked = false;

  /**
   * Initializes the controller class. This method is automatically called after the fxml file has
   * been loaded.
   */
  @FXML
  private void initialize() {
    System.out.println(mainBorderPane.getChildren().size());
    System.out.println(mainBorderPane.getChildren().get(1).toString());
    // imageViewEinstein.setEffect(new GaussianBlur(10));
    initializeCeiling(mainBorderPane);
    imageViewEinstein.setClip(ceiling);
  }

  private void initializeCeiling(BorderPane root) {
    ceiling = new Ellipse();
    ceiling.centerXProperty().bind(root.widthProperty().multiply(0.35));
    ceiling.centerYProperty().bind(root.heightProperty().multiply(0.1));
    ceiling.radiusXProperty().bind(root.widthProperty().multiply(0.5));
    ceiling.radiusYProperty().bind(root.heightProperty().multiply(0.25));
  }

  /**
   * Sets the stage of this dialog.
   *
   * @param dialogStage
   */
  public void setDialogStage(Stage dialogStage) {
    this.dialogStage = dialogStage;
    this.dialogStage.setHeight(TAMANO_PANTALLA);
    this.dialogStage.centerOnScreen();
    this.dialogStage.setResizable(false);
  }

  /**
   * Sets the person to be edited in the dialog.
   *
   * @param person
   */
  public void setPerson(Person person) {
    this.person = person;

    firstNameField.setText(person.getFirstName());
    lastNameField.setText(person.getLastName());
    streetField.setText(person.getStreet());
    postalCodeField.setText(Integer.toString(person.getPostalCode()));
    cityField.setText(person.getCity());
    birthdayField.setOnAction(
        e -> {
          person.setBirthday(birthdayField.getValue());
        });
  }

  /**
   * Returns true if the user clicked OK, false otherwise.
   *
   * @return
   */
  public boolean isOkClicked() {
    return okClicked;
  }

  /** Called when the user clicks ok. */
  @FXML
  private void handleOk() {
    if (isInputValid()) {
      person.setFirstName(firstNameField.getText());
      person.setLastName(lastNameField.getText());
      person.setStreet(streetField.getText());
      person.setPostalCode(Integer.parseInt(postalCodeField.getText()));
      person.setCity(cityField.getText());
      person.setBirthday(birthdayField.getValue());

      okClicked = true;
      dialogStage.close();
    }
  }

  /** Called when the user clicks cancel. */
  @FXML
  private void handleCancel() {
    dialogStage.close();
  }

  /**
   * Validates the user input in the text fields.
   *
   * @return true if the input is valid
   */
  private boolean isInputValid() {
    String errorMessage = "";

    if (firstNameField.getText() == null || firstNameField.getText().length() == 0) {
      errorMessage += "No valid first name!\n";
    }
    if (lastNameField.getText() == null || lastNameField.getText().length() == 0) {
      errorMessage += "No valid last name!\n";
    }
    if (streetField.getText() == null || streetField.getText().length() == 0) {
      errorMessage += "No valid street!\n";
    }

    if (postalCodeField.getText() == null || postalCodeField.getText().length() == 0) {
      errorMessage += "No valid postal code!\n";
    } else {
      // try to parse the postal code into an int.
      try {
        Integer.parseInt(postalCodeField.getText());
      } catch (NumberFormatException e) {
        errorMessage += "No valid postal code (must be an integer)!\n";
      }
    }

    if (cityField.getText() == null || cityField.getText().length() == 0) {
      errorMessage += "No valid city!\n";
    }

    if (birthdayField.getValue() == null) {
      errorMessage += "Mete una fecha\n";
    }

    if (errorMessage.length() == 0) {
      return true;
    } else {
      // Show the error message.
      Dialogs.create()
          .title("Invalid Fields")
          .masthead("Please correct invalid fields")
          .message(errorMessage)
          .showError();
      return false;
    }
  }
}
 @Override
 public ResourceFactory getResourceFactory(Screen screen) {
   return getES2ResourceFactory(screen.getAdapterOrdinal(), screen);
 }
 @Override
 public int getAdapterOrdinal(Screen screen) {
   return glFactory.getAdapterOrdinal(screen.getNativeScreen());
 }