Java Code Examples for javafx.scene.layout.StackPane#setAlignment()

The following examples show how to use javafx.scene.layout.StackPane#setAlignment() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JFXDialog.java    From JFoenix with Apache License 2.0 6 votes vote down vote up
private void initialize() {
    this.setVisible(false);
    this.getStyleClass().add(DEFAULT_STYLE_CLASS);
    this.transitionType.addListener((o, oldVal, newVal) -> {
        animation = getShowAnimation(transitionType.get());
    });

    contentHolder = new StackPane();
    contentHolder.setBackground(new Background(new BackgroundFill(Color.WHITE, new CornerRadii(2), null)));
    JFXDepthManager.setDepth(contentHolder, 4);
    contentHolder.setPickOnBounds(false);
    // ensure stackpane is never resized beyond it's preferred size
    contentHolder.setMaxSize(Region.USE_PREF_SIZE, Region.USE_PREF_SIZE);
    this.getChildren().add(contentHolder);
    this.getStyleClass().add("jfx-dialog-overlay-pane");
    StackPane.setAlignment(contentHolder, Pos.CENTER);
    this.setBackground(new Background(new BackgroundFill(Color.rgb(0, 0, 0, 0.1), null, null)));
    // close the dialog if clicked on the overlay pane
    if (overlayClose.get()) {
        this.addEventHandler(MouseEvent.MOUSE_PRESSED, closeHandler);
    }
    // prevent propagating the events to overlay pane
    contentHolder.addEventHandler(MouseEvent.ANY, e -> e.consume());
}
 
Example 2
Source File: BorderedTitledPane.java    From chart-fx with Apache License 2.0 6 votes vote down vote up
public BorderedTitledPane(final String titleString, final Node content) {
    getStylesheets().add(getClass().getResource("titled-border.css").toExternalForm());
    getStyleClass().add("bordered-titled-border");
    if (content == null) {
        throw new IllegalArgumentException("content must not be null");
    }

    title = new Label(titleString);
    title.getStyleClass().add("bordered-titled-title");
    StackPane.setAlignment(title, Pos.TOP_LEFT);

    contentPane = new StackPane();
    content.getStyleClass().add("bordered-titled-content");
    contentPane.getChildren().add(content);

    getChildren().addAll(contentPane, title);
}
 
Example 3
Source File: NewsPanel.java    From pdfsam with GNU Affero General Public License v3.0 6 votes vote down vote up
public NewsPanel() {
    getStyleClass().add("news-panel");
    getStyleClass().addAll(Style.CONTAINER.css());
    Button closeButton = FontAwesomeIconFactory.get().createIconButton(FontAwesomeIcon.TIMES);
    closeButton.getStyleClass().addAll("close-button");
    closeButton.setOnAction(e -> eventStudio().broadcast(HideNewsPanelRequest.INSTANCE));
    Label titleLabel = new Label(DefaultI18nContext.getInstance().i18n("What's new"));
    titleLabel.setPrefWidth(Integer.MAX_VALUE);
    titleLabel.getStyleClass().add("news-panel-title");

    StackPane top = new StackPane(titleLabel, closeButton);
    top.setAlignment(Pos.TOP_RIGHT);

    scroll.getStyleClass().add("scrollable-news");
    scroll.setHbarPolicy(ScrollBarPolicy.NEVER);
    scroll.setFitToHeight(true);
    scroll.setFitToWidth(true);
    getChildren().addAll(top, scroll);

    eventStudio().addAnnotatedListeners(this);
}
 
Example 4
Source File: Notification.java    From pdfsam with GNU Affero General Public License v3.0 5 votes vote down vote up
Notification(String title, Node content) {
    requireNotNullArg(content, "Notification content cannot be blank");
    getStyleClass().add("notification");
    getStyleClass().addAll(Style.CONTAINER.css());
    setId(UUID.randomUUID().toString());
    Button closeButton = FontAwesomeIconFactory.get().createIconButton(FontAwesomeIcon.TIMES);
    closeButton.getStyleClass().addAll("close-button");
    closeButton.setOnAction(e -> eventStudio().broadcast(new RemoveNotificationRequestEvent(getId())));
    Label titleLabel = new Label(title);
    titleLabel.setPrefWidth(Integer.MAX_VALUE);
    titleLabel.getStyleClass().add("notification-title");
    StackPane top = new StackPane(titleLabel, closeButton);
    top.setAlignment(Pos.TOP_RIGHT);
    getChildren().addAll(top, content);
    setOpacity(0);
    setOnMouseEntered(e -> {
        fade.stop();
        setOpacity(1);
    });
    setOnMouseClicked(e -> {
        setOnMouseEntered(null);
        setOnMouseExited(null);
        fade.stop();
        eventStudio().broadcast(new RemoveNotificationRequestEvent(getId()));
    });
    fade.setFromValue(1);
    fade.setToValue(0);
}
 
Example 5
Source File: LayoutHelpers.java    From houdoku with MIT License 5 votes vote down vote up
/**
 * Create the container for displaying a series cover, for use in FlowPane layouts where covers
 * are shown in a somewhat grid-like fashion.
 *
 * @param container the parent FlowPane container
 * @param title     the title of the series being represented
 * @param cover     the cover of the series being represented; this ImageView is not modified, a
 *                  copy is made to be used in the new container
 * @return a StackPane which displays the provided title and cover and can be added to the
 *         FlowPane
 */
public static StackPane createCoverContainer(FlowPane container, String title,
        ImageView cover) {
    StackPane result_pane = new StackPane();
    result_pane.setAlignment(Pos.BOTTOM_LEFT);

    // create the label for showing the series title
    Label label = new Label();
    label.setText(title);
    label.getStyleClass().add("coverLabel");
    label.setWrapText(true);

    // We create a new ImageView for the cell instead of using the result's cover ImageView
    // since we may not want to mess with the sizing of the result's cover -- particularly if we
    // want to have additional result layouts.
    ImageView image_view = new ImageView();
    applyCoverSizing(image_view);
    image_view.fitWidthProperty().bind(result_pane.prefWidthProperty());
    image_view.imageProperty().bind(cover.imageProperty());

    image_view.setEffect(COVER_ADJUST_DEFAULT);
    image_view.getStyleClass().add("coverImage");

    // create the mouse event handlers for the result pane
    result_pane.setOnMouseEntered(t -> {
        image_view.setEffect(COVER_ADJUST_HOVER);
        setChildButtonVisible(result_pane, true);
    });
    result_pane.setOnMouseExited(t -> {
        image_view.setEffect(COVER_ADJUST_DEFAULT);
        setChildButtonVisible(result_pane, false);
    });

    result_pane.getChildren().addAll(image_view, label);

    return result_pane;
}
 
Example 6
Source File: BorderedTitledPane.java    From mcaselector with MIT License 5 votes vote down vote up
BorderedTitledPane(Translation titleString, Node content) {
	Label title = new Label(" " + titleString.toString() + " ");
	title.getStyleClass().remove("label");
	title.getStyleClass().add("bordered-titled-title");
	StackPane.setAlignment(title, Pos.TOP_LEFT);

	StackPane contentPane = new StackPane();
	content.getStyleClass().add("bordered-titled-content");
	StackPane.setAlignment(content, Pos.CENTER_LEFT);
	contentPane.getChildren().add(content);

	getStyleClass().add("bordered-titled-border");
	getChildren().addAll(title, contentPane);
}
 
Example 7
Source File: MetaStone.java    From metastone with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void start(Stage primaryStage) throws Exception {
	primaryStage.setTitle("MetaStone");
	primaryStage.initStyle(StageStyle.UNIFIED);
	primaryStage.setResizable(false);
	primaryStage.getIcons().add(new Image(IconFactory.getImageUrl("ui/app_icon.png")));

	ApplicationFacade facade = (ApplicationFacade) ApplicationFacade.getInstance();
	facade.startUp();

	StackPane root = new StackPane();
	root.setAlignment(Pos.CENTER);
	Scene scene = new Scene(root);
	scene.getStylesheets().add(getClass().getResource("/css/main.css").toExternalForm());
	primaryStage.setScene(scene);
	
	// implementing potential visual fix for JavaFX
	// setting the visual opacity to zero, and then
	// once the stage is shown, setting the opacity to one.
	// this fixes an issue where some users would only see a blank
	// screen on application startup
	primaryStage.setOpacity(0.0);
	
	facade.sendNotification(GameNotification.CANVAS_CREATED, root);
	facade.sendNotification(GameNotification.MAIN_MENU);
	primaryStage.show();
	
	// setting opacity to one for JavaFX hotfix
	primaryStage.setOpacity(1.0);
	
	facade.sendNotification(GameNotification.CHECK_FOR_UPDATE);
}
 
Example 8
Source File: CustomOverlay.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
public CustomOverlay(Workbench workbench, boolean blocking) {
  StackPane.setAlignment(this, Pos.CENTER);
  Objects.requireNonNull(workbench);
  this.workbench = workbench;
  this.blocking = blocking;
  init();
}
 
Example 9
Source File: ToolBarFlowPane.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
/**
 * @param chart the associated chart pane
 */
public ToolBarFlowPane(final Chart chart) {
    super();
    this.chart = chart;

    this.setId(this.getClass().getSimpleName() + "(Chart)"); // N.B. not a unique name but for testing this suffices
    StackPane.setAlignment(this, Pos.TOP_CENTER);
    this.setPrefHeight(USE_COMPUTED_SIZE);
    this.setBackground(new Background(new BackgroundFill(defaultColour, CornerRadii.EMPTY, Insets.EMPTY)));
    this.setMinHeight(0);

    this.setShape(ToolBarShapeHelper.getToolBarShape(this.getWidth(), this.getHeight(), cornerRadius.get()));

    this.setAlignment(Pos.TOP_CENTER);
    this.setMinWidth(0);
    setPadding(calculateInsets()); // NOPMD
    HBox.setHgrow(this, Priority.NEVER);

    ChangeListener<Number> toolBarSizeListener = (ch, o, n) -> {
        if (n.equals(o)) {
            return;
        }
        adjustToolBarWidth();
    };

    this.widthProperty().addListener(toolBarSizeListener);
    this.heightProperty().addListener(toolBarSizeListener);
    chart.getCanvas().widthProperty().addListener(toolBarSizeListener);
    cornerRadius.addListener(toolBarSizeListener);
}
 
Example 10
Source File: ViewNumberProgress.java    From helloiot with GNU General Public License v3.0 5 votes vote down vote up
@Override
protected Node constructContent() {
    VBox vboxroot = new VBox();
    vboxroot.setSpacing(10.0);        
            
    boxview = new HBox();
    boxview.setSpacing(6.0);
    
    level = new Label();
    level.setAlignment(Pos.CENTER_RIGHT);
    level.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE);
    level.getStyleClass().add("unitmaintext");
    HBox.setHgrow(level, Priority.SOMETIMES);
    
    boxview.getChildren().add(level);
    
    // Get all data

    progress = new ProgressBar();
    progress.getStyleClass().add("unitbar");
    progress.setFocusTraversable(false);
    progress.setMaxWidth(Double.MAX_VALUE);
    StackPane.setAlignment(progress, Pos.BOTTOM_CENTER);          

    StackPane stack = new StackPane(progress);
    VBox.setVgrow(stack, Priority.SOMETIMES);   
    vboxroot.getChildren().addAll(boxview, stack);
    
    initialize();
    return vboxroot;
}
 
Example 11
Source File: InputField.java    From arma-dialog-creator with MIT License 5 votes vote down vote up
public ErrorMsgPopup(@NotNull InputField inputField) {
	this.inputField = inputField;
	StackPane stackPane = new StackPane(lblMsg);
	stackPane.setPadding(new Insets(5));
	stackPane.setAlignment(Pos.BOTTOM_CENTER);
	stackPane.setStyle("-fx-background-color:red;");
	lblMsg.setTextFill(Color.WHITE);
	this.setAutoHide(true);

	getContent().add(stackPane);
}
 
Example 12
Source File: TinySpinner.java    From milkman with MIT License 5 votes vote down vote up
public TinySpinner() {
	this.getStyleClass().add("spinner");
	this.getChildren().add(spinner("tiny-spinner", -40));
	
	cancellation = button("tiny-cancellation", icon(FontAwesomeIcon.TIMES, "1.5em"));
	StackPane.setAlignment(cancellation, Pos.CENTER);
	this.getChildren().add(cancellation);
}
 
Example 13
Source File: ValidationPane.java    From JFoenix with Apache License 2.0 5 votes vote down vote up
private void showError(ValidatorBase validator) {
    // set text in error label
    errorLabel.setText(validator.getMessage());
    // show error icon
    Node icon = validator.getIcon();
    errorIcon.getChildren().clear();
    if (icon != null) {
        errorIcon.getChildren().setAll(icon);
        StackPane.setAlignment(icon, Pos.CENTER_RIGHT);
    }
    setVisible(true);
}
 
Example 14
Source File: ListKMLContentsSample.java    From arcgis-runtime-samples-java with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {

  try {
    // create stack pane and application scene
    StackPane stackPane = new StackPane();
    Scene fxScene = new Scene(stackPane);

    // set title, size, and add scene to stage
    stage.setTitle("List KML Contents Sample");
    stage.setWidth(800);
    stage.setHeight(700);
    stage.setScene(fxScene);
    stage.show();

    // create a map and add it to the map view
    ArcGISScene scene = new ArcGISScene(Basemap.createImageryWithLabels());
    sceneView = new SceneView();
    sceneView.setArcGISScene(scene);

    // load a KML dataset from a local KMZ file and show it as an operational layer
    File kmzFile = new File(System.getProperty("data.dir"), "./samples-data/kml/esri_test_data.kmz");
    KmlDataset kmlDataset = new KmlDataset(kmzFile.getAbsolutePath());
    KmlLayer kmlLayer = new KmlLayer(kmlDataset);
    scene.getOperationalLayers().add(kmlLayer);

    // create a tree view to list the contents of the KML dataset
    TreeView<KmlNode> kmlTree = new TreeView<>();
    kmlTree.setMaxSize(300, 400);
    TreeItem<KmlNode> root = new TreeItem<>(null);
    kmlTree.setRoot(root);
    kmlTree.setShowRoot(false);

    // when the dataset is loaded, recursively build the tree view with KML nodes starting with the root node(s)
    kmlDataset.addDoneLoadingListener(() -> kmlDataset.getRootNodes().forEach(kmlNode -> {
      TreeItem<KmlNode> kmlNodeTreeItem = buildTree(new TreeItem<>(kmlNode));
      root.getChildren().add(kmlNodeTreeItem);
    }));

    // show the KML node in the tree view with its name and type
    kmlTree.setCellFactory(param -> new TextFieldTreeCell<>(new StringConverter<KmlNode>() {

      @Override
      public String toString(KmlNode node) {
        String type = null;
        if (node instanceof KmlDocument) {
          type = "KmlDocument";
        } else if (node instanceof KmlFolder) {
          type = "KmlFolder";
        } else if (node instanceof KmlGroundOverlay) {
          type = "KmlGroundOverlay";
        } else if (node instanceof KmlScreenOverlay) {
          type = "KmlScreenOverlay";
        } else if (node instanceof KmlPlacemark) {
            type = "KmlPlacemark";
        }
        return node.getName() + " - " + type;
      }

      @Override
      public KmlNode fromString(String string) {
        return null; //not needed
      }
    }));

    // when a tree item is selected, zoom to its node's extent (if it has one)
    kmlTree.getSelectionModel().selectedItemProperty().addListener(o -> {
      TreeItem<KmlNode> selectedTreeItem = kmlTree.getSelectionModel().getSelectedItem();
      KmlNode selectedNode = selectedTreeItem.getValue();
      Envelope nodeExtent = selectedNode.getExtent();
      if (nodeExtent != null && !nodeExtent.isEmpty()) {
        sceneView.setViewpointAsync(new Viewpoint(nodeExtent));
      }
    });

    // add the map view to stack pane
    stackPane.getChildren().addAll(sceneView, kmlTree);
    StackPane.setAlignment(kmlTree, Pos.TOP_LEFT);
    StackPane.setMargin(kmlTree, new Insets(10));
  } catch (Exception e) {
    // on any error, display the stack trace.
    e.printStackTrace();
  }
}
 
Example 15
Source File: LocalServerMapImageLayerSample.java    From arcgis-runtime-samples-java with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {

  try {
    // create stack pane and application scene
    StackPane stackPane = new StackPane();
    Scene scene = new Scene(stackPane);

    // set title, size, and add scene to stage
    stage.setTitle("Local Server Map Image Layer Sample");
    stage.setWidth(APPLICATION_WIDTH);
    stage.setHeight(700);
    stage.setScene(scene);
    stage.show();

    // create a view with a map and basemap
    ArcGISMap map = new ArcGISMap(Basemap.createStreets());
    mapView = new MapView();
    mapView.setMap(map);

    // track progress of loading map image layer to map
    imageLayerProgress = new ProgressIndicator(ProgressIndicator.INDETERMINATE_PROGRESS);
    imageLayerProgress.setMaxWidth(30);

    // check that local server install path can be accessed
    if (LocalServer.INSTANCE.checkInstallValid()) {
      LocalServer server = LocalServer.INSTANCE;
      // start local server
      server.addStatusChangedListener(status -> {
        if (status.getNewStatus() == LocalServerStatus.STARTED) {
          // start map image service
          String mapServiceURL = new File(System.getProperty("data.dir"), "./samples-data/local_server/RelationshipID.mpk").getAbsolutePath();
          mapImageService = new LocalMapService(mapServiceURL);
          mapImageService.addStatusChangedListener(this::addLocalMapImageLayer);
          mapImageService.startAsync();
        }
      });
      server.startAsync();
    } else {
      Platform.runLater(() -> {
        Alert dialog = new Alert(AlertType.INFORMATION);
        dialog.initOwner(mapView.getScene().getWindow());
        dialog.setHeaderText("Local Server Load Error");
        dialog.setContentText("Local Geoprocessing Failed to load.");
        dialog.show();
      });
    }

    // add view to application window with progress bar
    stackPane.getChildren().addAll(mapView, imageLayerProgress);
    StackPane.setAlignment(imageLayerProgress, Pos.CENTER);
  } catch (Exception e) {
    // on any error, display the stack trace.
    e.printStackTrace();
  }
}
 
Example 16
Source File: FeatureLayerExtrusionSample.java    From arcgis-runtime-samples-java with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {

  StackPane stackPane = new StackPane();
  Scene fxScene = new Scene(stackPane);
  // for adding styling to any controls that are added
  fxScene.getStylesheets().add(getClass().getResource("/feature_layer_extrusion/style.css").toExternalForm());

  // set title, size, and add scene to stage
  stage.setTitle("Feature Layer Extrusion Sample");
  stage.setWidth(800);
  stage.setHeight(700);
  stage.setScene(fxScene);
  stage.show();

  // so scene can be visible within application
  ArcGISScene scene = new ArcGISScene(Basemap.createTopographic());
  sceneView = new SceneView();
  sceneView.setArcGISScene(scene);
  stackPane.getChildren().add(sceneView);

  // get us census data as a service feature table
  ServiceFeatureTable statesServiceFeatureTable = new ServiceFeatureTable("https://sampleserver6.arcgisonline.com/arcgis/rest/services/Census/MapServer/3");

  // creates feature layer from table and add to scene
  final FeatureLayer statesFeatureLayer = new FeatureLayer(statesServiceFeatureTable);
  // feature layer must be rendered dynamically for extrusion to work
  statesFeatureLayer.setRenderingMode(FeatureLayer.RenderingMode.DYNAMIC);
  scene.getOperationalLayers().add(statesFeatureLayer);

  // symbols are used to display features (US states) from table
  SimpleLineSymbol lineSymbol = new SimpleLineSymbol(SimpleLineSymbol.Style.SOLID, 0xFF000000, 1.0f);
  SimpleFillSymbol fillSymbol = new SimpleFillSymbol(SimpleFillSymbol.Style.SOLID, 0xFF0000FF, lineSymbol);
  final SimpleRenderer renderer = new SimpleRenderer(fillSymbol);
  // set the extrusion mode to absolute height
  renderer.getSceneProperties().setExtrusionMode(Renderer.SceneProperties.ExtrusionMode.ABSOLUTE_HEIGHT);
  statesFeatureLayer.setRenderer(renderer);

  // set camera to focus on state features
  Point lookAtPoint = new Point(-10974490, 4814376, 0, SpatialReferences.getWebMercator());
  sceneView.setViewpointCamera(new Camera(lookAtPoint, 10000000, 0, 20, 0));

  // create a combo box to choose between different expressions/attributes to extrude by
  ComboBox<ExtrusionAttribute> attributeComboBox = new ComboBox<>();
  attributeComboBox.setCellFactory(list -> new ListCell<ExtrusionAttribute> (){
    @Override
    protected void updateItem(ExtrusionAttribute attribute, boolean bln) {

      super.updateItem(attribute, bln);
      if (attribute != null) {
        setText(attribute.getName());
      }
    }
  });
  attributeComboBox.setConverter(new StringConverter<ExtrusionAttribute>() {

    @Override
    public String toString(ExtrusionAttribute travelMode) {
      return travelMode != null ? travelMode.getName() : "";
    }

    @Override
    public ExtrusionAttribute fromString(String fileName) {
      return null;
    }
  });
  // scale down outlier populations
  ExtrusionAttribute populationDensity = new ExtrusionAttribute("Population Density","[POP07_SQMI] * 5000 + 100000");
  // scale up density
  ExtrusionAttribute totalPopulation = new ExtrusionAttribute("Total Population", "[POP2007]/ 10");
  attributeComboBox.setItems(FXCollections.observableArrayList(populationDensity, totalPopulation));
  stackPane.getChildren().add(attributeComboBox);
  StackPane.setAlignment(attributeComboBox, Pos.TOP_LEFT);
  StackPane.setMargin(attributeComboBox, new Insets(10, 0, 0, 10));

  // set the extrusion expression on the renderer when one is chosen in the combo box
  attributeComboBox.getSelectionModel().selectedItemProperty().addListener(e -> {
    ExtrusionAttribute selectedAttribute = attributeComboBox.getSelectionModel().getSelectedItem();
    renderer.getSceneProperties().setExtrusionExpression(selectedAttribute.getExpression());
  });

  // start with total population selected
  attributeComboBox.getSelectionModel().select(totalPopulation);
}
 
Example 17
Source File: ChangeAtmosphereEffectSample.java    From arcgis-runtime-samples-java with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {

  try {
    // create stack pane and JavaFX app scene
    StackPane stackPane = new StackPane();
    Scene fxScene = new Scene(stackPane);
    fxScene.getStylesheets().add(getClass().getResource("/change_atmosphere_effect/style.css").toExternalForm());

    // set title, size, and add JavaFX scene to stage
    stage.setTitle("Change Atmosphere Effect Sample");
    stage.setWidth(800);
    stage.setHeight(700);
    stage.setScene(fxScene);
    stage.show();

    // create a scene and add a basemap to it
    ArcGISScene scene = new ArcGISScene();
    scene.setBasemap(Basemap.createImagery());

    // set the scene to a scene view
    sceneView = new SceneView();
    sceneView.setArcGISScene(scene);

    // add base surface for elevation data
    Surface surface = new Surface();
    ArcGISTiledElevationSource elevationSource = new ArcGISTiledElevationSource(
            "https://elevation3d.arcgis.com/arcgis/rest/services/WorldElevation3D/Terrain3D/ImageServer");
    surface.getElevationSources().add(elevationSource);
    scene.setBaseSurface(surface);

    // add a camera and initial camera position
    Camera camera = new Camera(64.416919, -14.483728, 100, 318, 105, 0);
    sceneView.setViewpointCamera(camera);

    // create a control panel
    VBox controlsVBox = new VBox(6);
    controlsVBox.setBackground(new Background(new BackgroundFill(Paint.valueOf("rgba(0, 0, 0, 0.3)"),
        CornerRadii.EMPTY, Insets.EMPTY)));
    controlsVBox.setPadding(new Insets(10.0));
    controlsVBox.setMaxSize(260, 110);
    controlsVBox.getStyleClass().add("panel-region");

    // create buttons to set each atmosphere effect
    Button noAtmosphereButton = new Button("No Atmosphere Effect");
    Button realisticAtmosphereButton = new Button ("Realistic Atmosphere Effect");
    Button horizonAtmosphereButton = new Button ("Horizon Only Atmosphere Effect");
    noAtmosphereButton.setMaxWidth(Double.MAX_VALUE);
    realisticAtmosphereButton.setMaxWidth(Double.MAX_VALUE);
    horizonAtmosphereButton.setMaxWidth(Double.MAX_VALUE);

    noAtmosphereButton.setOnAction(event -> sceneView.setAtmosphereEffect(AtmosphereEffect.NONE));
    realisticAtmosphereButton.setOnAction(event -> sceneView.setAtmosphereEffect(AtmosphereEffect.REALISTIC));
    horizonAtmosphereButton.setOnAction(event -> sceneView.setAtmosphereEffect(AtmosphereEffect.HORIZON_ONLY));

    // add buttons to the control panel
    controlsVBox.getChildren().addAll(noAtmosphereButton, realisticAtmosphereButton, horizonAtmosphereButton);

    // add scene view and control panel to the stack pane
    stackPane.getChildren().addAll(sceneView, controlsVBox);
    StackPane.setAlignment(controlsVBox, Pos.TOP_RIGHT);
    StackPane.setMargin(controlsVBox, new Insets(10, 0, 0, 10));
  } catch (Exception e) {
    // on any error, display the stack trace.
    e.printStackTrace();
  }
}
 
Example 18
Source File: JFXDrawer.java    From JFoenix with Apache License 2.0 4 votes vote down vote up
/**
 * This method will change the drawer behavior according to the argument direction.
 *
 * @param dir - The direction that the drawer will enter the screen from.
 */
private void updateDirection(DrawerDirection dir) {
    maxSizeProperty.set(-1);
    prefSizeProperty.set(-1);
    // reset old translation
    translateProperty.set(0);

    // update properties
    if (dir == DrawerDirection.LEFT || dir == DrawerDirection.RIGHT) {
        // set the new translation property
        translateProperty.removeListener(translateChangeListener);
        translateProperty = sidePane.translateXProperty();
        translateProperty.addListener(translateChangeListener);
        // change the size property
        maxSizeProperty = sidePane.maxWidthProperty();
        prefSizeProperty = sidePane.prefWidthProperty();
        sizeProperty = sidePane.widthProperty();
        paddingSizeProperty = paddingPane.minWidthProperty();
    } else if (dir == DrawerDirection.TOP || dir == DrawerDirection.BOTTOM) {
        // set the new translation property
        translateProperty.removeListener(translateChangeListener);
        translateProperty = sidePane.translateYProperty();
        translateProperty.addListener(translateChangeListener);
        // change the size property
        maxSizeProperty = sidePane.maxHeightProperty();
        prefSizeProperty = sidePane.prefHeightProperty();
        sizeProperty = sidePane.heightProperty();
        paddingSizeProperty = paddingPane.minHeightProperty();
    }
    // update pane alignment
    if (dir == DrawerDirection.LEFT) {
        StackPane.setAlignment(sidePane, Pos.CENTER_LEFT);
    } else if (dir == DrawerDirection.RIGHT) {
        StackPane.setAlignment(sidePane, Pos.CENTER_RIGHT);
    } else if (dir == DrawerDirection.TOP) {
        StackPane.setAlignment(sidePane, Pos.TOP_CENTER);
    } else if (dir == DrawerDirection.BOTTOM) {
        StackPane.setAlignment(sidePane, Pos.BOTTOM_CENTER);
    }

    setDefaultDrawerSize(getDefaultDrawerSize());
    updateDrawerAnimation(initTranslate.get());
    updateContent();
    setMiniDrawerSize(getMiniDrawerSize());
}
 
Example 19
Source File: TimelinePanel.java    From constellation with Apache License 2.0 4 votes vote down vote up
/**
     * Creates organises the TimelinePanel's layers.
     */
    private void doLayout() {
        // Layer that contains the timelinechart component:
        final BorderPane timelinePane = new BorderPane();

        timelinePane.setCenter(timeline);
        // The layer that contains the time extent labels:
        final BorderPane labelsPane = new BorderPane();
        BorderPane.setAlignment(lowerTime, Pos.CENTER);
        BorderPane.setAlignment(upperTime, Pos.CENTER);
        BorderPane.setMargin(lowerTime, new Insets(-32.0, -40.0, 0.0, -60.0));
        BorderPane.setMargin(upperTime, new Insets(-32.0, -60.0, 0.0, -40.0));
        labelsPane.setLeft(lowerTime);
        labelsPane.setRight(upperTime);
        labelsPane.setMouseTransparent(true);

        // Layer that combines the newly constructed time-extents with the timeline layer:
        final StackPane stackPane = new StackPane();
        StackPane.setAlignment(labelsPane, Pos.CENTER);
//        extentLabelPane.maxHeightProperty().bind(stackPane.heightProperty());
        StackPane.setAlignment(timelinePane, Pos.CENTER);
//        timelinePane.prefHeightProperty().bind(stackPane.heightProperty());
        stackPane.setPadding(Insets.EMPTY);
        stackPane.getChildren().addAll(timelinePane, labelsPane);

        // Layout the menu bar and the timeline object:
        final VBox vbox = new VBox();
//        stackPane.prefHeightProperty().bind(vbox.heightProperty());
        VBox.setVgrow(toolbar, Priority.NEVER);
        VBox.setVgrow(stackPane, Priority.ALWAYS);
        vbox.getChildren().addAll(toolbar, stackPane);
        vbox.setAlignment(Pos.TOP_CENTER);
        vbox.setFillWidth(true);

        // Organise the inner pane:
        AnchorPane.setTopAnchor(vbox, 0d);
        AnchorPane.setBottomAnchor(vbox, 0d);
        AnchorPane.setLeftAnchor(vbox, 0d);
        AnchorPane.setRightAnchor(vbox, 0d);
        innerPane.getChildren().add(vbox);
        innerPane.prefHeightProperty().bind(super.heightProperty());
        innerPane.prefWidthProperty().bind(super.widthProperty());

        // Attach the inner pane to the root:
        this.getChildren().add(innerPane);
    }
 
Example 20
Source File: CheckboxSample.java    From marathonv5 with Apache License 2.0 4 votes vote down vote up
@Override
public void start(Stage stage) {
    Scene scene = new Scene(new Group());
    stage.setTitle("Checkbox Sample");
    stage.setWidth(250);
    stage.setHeight(150);

    rect.setArcHeight(10);
    rect.setArcWidth(10);
    rect.setFill(Color.rgb(41, 41, 41));

    for (int i = 0; i < names.length; i++) {
        final Image image = images[i] = new Image(getClass().getResourceAsStream(names[i] + ".png"));
        final ImageView icon = icons[i] = new ImageView();
        final CheckBox cb = cbs[i] = new CheckBox(names[i]);
        cb.selectedProperty().addListener((ObservableValue<? extends Boolean> ov, Boolean old_val, Boolean new_val) -> {
            icon.setImage(new_val ? image : null);
        });
    }

    VBox vbox = new VBox();
    vbox.getChildren().addAll(cbs);
    vbox.setSpacing(5);

    HBox hbox = new HBox();
    hbox.getChildren().addAll(icons);
    hbox.setPadding(new Insets(0, 0, 0, 5));

    StackPane stack = new StackPane();

    stack.getChildren().add(rect);
    stack.getChildren().add(hbox);
    StackPane.setAlignment(rect, Pos.TOP_CENTER);

    HBox root = new HBox();
    root.getChildren().add(vbox);
    root.getChildren().add(stack);
    root.setSpacing(40);
    root.setPadding(new Insets(20, 10, 10, 20));

    ((Group) scene.getRoot()).getChildren().add(root);

    stage.setScene(scene);
    stage.show();
}