List of usage examples for javafx.scene.layout BorderPane setAlignment
public static void setAlignment(Node child, Pos value)
From source file:mesclasses.objects.LoadWindow.java
private Scene createloadingScene() { bar = new ProgressBar(); vbox = new VBox(); BorderPane p = new BorderPane(); p.setCenter(bar);// ww w .j a va2s .c o m p.setTop(vbox); BorderPane.setAlignment(vbox, Pos.CENTER); return new Scene(p, 300, 150); }
From source file:com.bdb.weather.display.current.Hygrometer.java
/** * Constructor./*from w w w . j ava 2 s . com*/ * * @param titleString The title to add to the panel that contains the gauge */ public Hygrometer(String titleString) { this.setPrefSize(200.0, 200.0); ChartViewer chartViewer = createChartElements(); this.setTop(title); this.setCenter(chartViewer); BorderPane.setAlignment(title, Pos.CENTER); title.textProperty().bind(titleProperty); setTitle(titleString); }
From source file:com.bdb.weather.display.current.Barometer.java
/** * Constructor./*from w w w .j a va2 s. com*/ * * @param titleString The title to display with the dial * @param min The minimum of the dial's scale * @param max The maximum of the dial's scale */ private Barometer(String titleString, Pressure min, Pressure max) { title.setText(titleString); ChartViewer chartViewer = createChartElements(min, max); this.setTop(title); this.setCenter(chartViewer); BorderPane.setAlignment(title, Pos.CENTER); }
From source file:MediaControl.java
public MediaControl(final MediaPlayer mp) { this.mp = mp; setStyle("-fx-background-color: #bfc2c7;"); mediaView = new MediaView(mp); Pane mvPane = new Pane() { };/*w ww .java2s . co m*/ mvPane.getChildren().add(mediaView); mvPane.setStyle("-fx-background-color: black;"); setCenter(mvPane); mediaBar = new HBox(); mediaBar.setAlignment(Pos.CENTER); mediaBar.setPadding(new Insets(5, 10, 5, 10)); BorderPane.setAlignment(mediaBar, Pos.CENTER); final Button playButton = new Button(">"); playButton.setOnAction(new EventHandler<ActionEvent>() { public void handle(ActionEvent e) { Status status = mp.getStatus(); if (status == Status.UNKNOWN || status == Status.HALTED) { // don't do anything in these states return; } if (status == Status.PAUSED || status == Status.READY || status == Status.STOPPED) { // rewind the movie if we're sitting at the end if (atEndOfMedia) { mp.seek(mp.getStartTime()); atEndOfMedia = false; } mp.play(); } else { mp.pause(); } } }); mp.currentTimeProperty().addListener(new InvalidationListener() { public void invalidated(Observable ov) { updateValues(); } }); mp.setOnPlaying(new Runnable() { public void run() { if (stopRequested) { mp.pause(); stopRequested = false; } else { playButton.setText("||"); } } }); mp.setOnPaused(new Runnable() { public void run() { System.out.println("onPaused"); playButton.setText(">"); } }); mp.setOnReady(new Runnable() { public void run() { duration = mp.getMedia().getDuration(); updateValues(); } }); mp.setCycleCount(repeat ? MediaPlayer.INDEFINITE : 1); mp.setOnEndOfMedia(new Runnable() { public void run() { if (!repeat) { playButton.setText(">"); stopRequested = true; atEndOfMedia = true; } } }); mediaBar.getChildren().add(playButton); // Add spacer Label spacer = new Label(" "); mediaBar.getChildren().add(spacer); // Add Time label Label timeLabel = new Label("Time: "); mediaBar.getChildren().add(timeLabel); // Add time slider timeSlider = new Slider(); HBox.setHgrow(timeSlider, Priority.ALWAYS); timeSlider.setMinWidth(50); timeSlider.setMaxWidth(Double.MAX_VALUE); timeSlider.valueProperty().addListener(new InvalidationListener() { public void invalidated(Observable ov) { if (timeSlider.isValueChanging()) { // multiply duration by percentage calculated by slider position mp.seek(duration.multiply(timeSlider.getValue() / 100.0)); } } }); mediaBar.getChildren().add(timeSlider); // Add Play label playTime = new Label(); playTime.setPrefWidth(130); playTime.setMinWidth(50); mediaBar.getChildren().add(playTime); // Add the volume label Label volumeLabel = new Label("Vol: "); mediaBar.getChildren().add(volumeLabel); // Add Volume slider volumeSlider = new Slider(); volumeSlider.setPrefWidth(70); volumeSlider.setMaxWidth(Region.USE_PREF_SIZE); volumeSlider.setMinWidth(30); volumeSlider.valueProperty().addListener(new InvalidationListener() { public void invalidated(Observable ov) { if (volumeSlider.isValueChanging()) { mp.setVolume(volumeSlider.getValue() / 100.0); } } }); mediaBar.getChildren().add(volumeSlider); setBottom(mediaBar); }
From source file:Main.java
@Override public void start(final Stage stage) { final Node loginPanel = makeDraggable(createLoginPanel()); final Node confirmationPanel = makeDraggable(createConfirmationPanel()); final Node progressPanel = makeDraggable(createProgressPanel()); loginPanel.relocate(0, 0);/* w w w . ja v a2 s . co m*/ confirmationPanel.relocate(0, 67); progressPanel.relocate(0, 106); final Pane panelsPane = new Pane(); panelsPane.getChildren().addAll(loginPanel, confirmationPanel, progressPanel); final BorderPane sceneRoot = new BorderPane(); BorderPane.setAlignment(panelsPane, Pos.TOP_LEFT); sceneRoot.setCenter(panelsPane); final CheckBox dragModeCheckbox = new CheckBox("Drag mode"); BorderPane.setMargin(dragModeCheckbox, new Insets(6)); sceneRoot.setBottom(dragModeCheckbox); dragModeActiveProperty.bind(dragModeCheckbox.selectedProperty()); final Scene scene = new Scene(sceneRoot, 400, 300); stage.setScene(scene); stage.setTitle("Draggable Panels Example"); stage.show(); }
From source file:cz.lbenda.gui.controls.TextAreaFrmController.java
/** Create button which can open text editor */ public static Button createOpenButton(String windowTitle, @Nonnull Supplier<String> oldValueSupplier, @Nonnull Consumer<String> newValueConsumer) { String title = windowTitle == null ? msgDefaultWindowTitle : windowTitle; Button result = new Button(null, new ImageView(BUTTON_IMAGE)); result.setTooltip(new Tooltip(msgBtnOpenInEditor_tooltip)); BorderPane.setAlignment(result, Pos.TOP_RIGHT); result.setOnAction(event -> {//from w ww . j ava 2 s .c o m Tuple2<Parent, TextAreaFrmController> tuple2 = TextAreaFrmController.createNewInstance(); tuple2.get2().textProperty().setValue(oldValueSupplier.get()); tuple2.get2().textProperty() .addListener((observable, oldValue, newValue) -> newValueConsumer.accept(newValue)); Stage stage = (Stage) ((Node) event.getSource()).getScene().getWindow(); DialogHelper.getInstance().openWindowInCenterOfStage(stage, tuple2.get2().getMainPane(), title); }); return result; }
From source file:com.bdb.weather.display.current.WindGauge.java
/** * Constructor.//from w w w .j a v a2 s .c om */ public WindGauge() { this.setPrefSize(200.0, 200.0); lastHeading = 0.0; lastSpeed = 0.0; plot = new DialPlot(); for (int i = 0; i < WIND_DIR_ITEMS; i++) { datasets[i] = new DefaultValueDataset(); plot.setDataset(WIND_DIR_DATASET_INDEX_BASE + i, datasets[i]); } plot.setDataset(WIND_SPEED_DATASET_INDEX, speedDataset); plot.setDataset(WIND_GUST_DATASET_INDEX, gustDataset); plot.setDataset(MAX_WIND_SPEED_DATASET_INDEX, maxSpeedDataset); plot.setDataset(MAX_WIND_GUST_DATASET_INDEX, maxGustDataset); plot.addLayer( new DialBackground(new GradientPaint(0.0f, 0.0f, Color.LIGHT_GRAY, 100.0f, 0.0f, Color.blue))); StandardDialScale scale = new StandardDialScale(0.0, 360.0, 90.0, -360.0, 45.0, 1); scale.setTickLabelFont(scale.getTickLabelFont().deriveFont(14.0F).deriveFont(Font.PLAIN)); scale.setTickRadius(.9); scale.setTickLabelFormatter(new CompassHeadingFormat()); scale.setTickLabelOffset(0.06); scale.setMajorTickPaint(new Color(0, 0, 0, 0)); scale.setTickLabelPaint(Color.BLACK); scale.setMinorTickLength(scale.getMajorTickLength()); scale.setMinorTickStroke(scale.getMajorTickStroke()); plot.addScale(WIND_DIR_SCALE, scale); scale = new StandardDialScale(0.0, 50.0, 225.0, -270.0, 10.0, 9); scale.setTickLabelFont(scale.getTickLabelFont().deriveFont(14.0F).deriveFont(Font.PLAIN)); scale.setTickRadius(.4); scale.setTickLabelFormatter(new DecimalFormat("##")); scale.setTickLabelOffset(.15); scale.setTickLabelPaint(Color.BLACK); plot.addScale(WIND_SPEED_SCALE, scale); DialPointer.Pointer pointer; for (int i = 1; i < WIND_DIR_ITEMS; i++) { pointer = new WindDirPointer(.72, .2, WIND_DIR_DATASET_INDEX_BASE + i, false); pointer.setOutlinePaint(Color.RED); plot.addPointer(pointer); } plot.setDialFrame(new StandardDialFrame()); pointer = new WindDirPointer(.72, .2, WIND_DIR_DATASET_INDEX_BASE, true); Color fill = Color.CYAN; pointer.setFillPaint(fill); pointer.setOutlinePaint(Color.BLACK); plot.addPointer(pointer); DialCap cap = new DialCap(); plot.setCap(cap); DialPointer.Pin speedPin = new DialPointer.Pin(WIND_SPEED_DATASET_INDEX); speedPin.setPaint(WIND_SPEED_PIN_COLOR); speedPin.setRadius(WIND_SPEED_PIN_RADIUS); speedPin.setStroke(new BasicStroke(WIND_SPEED_PIN_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); plot.addPointer(speedPin); DialPointer.Pin gustPin = new DialPointer.Pin(WIND_GUST_DATASET_INDEX); gustPin.setPaint(WIND_GUST_PIN_COLOR); gustPin.setRadius(WIND_GUST_PIN_RADIUS); gustPin.setStroke(new BasicStroke(WIND_SPEED_PIN_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); plot.addPointer(gustPin); DialPointer.Pin maxSpeedPin = new DialPointer.Pin(MAX_WIND_SPEED_DATASET_INDEX); maxSpeedPin.setPaint(WIND_SPEED_PIN_COLOR); maxSpeedPin.setRadius(MAX_WIND_SPEED_PIN_RADIUS); maxSpeedPin .setStroke(new BasicStroke(MAX_WIND_SPEED_PIN_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); plot.addPointer(maxSpeedPin); DialPointer.Pin maxGustPin = new DialPointer.Pin(MAX_WIND_GUST_DATASET_INDEX); maxGustPin.setPaint(WIND_GUST_PIN_COLOR); maxGustPin.setRadius(MAX_WIND_GUST_PIN_RADIUS); maxGustPin .setStroke(new BasicStroke(MAX_WIND_SPEED_PIN_WIDTH, BasicStroke.CAP_BUTT, BasicStroke.JOIN_BEVEL)); plot.addPointer(maxGustPin); speedAnnotation.setAngle(270.0); speedAnnotation.setRadius(.35); speedAnnotation.setPaint(Color.cyan); plot.addLayer(speedAnnotation); double angle = speedAnnotation.getAngle(); double radius = speedAnnotation.getRadius(); avgAnnotation.setPaint(Color.cyan); avgAnnotation.setAngle(angle); avgAnnotation.setRadius(radius + .1); plot.addLayer(avgAnnotation); for (int i = 0; i < WIND_DIR_ITEMS; i++) plot.mapDatasetToScale(WIND_DIR_DATASET_INDEX_BASE + i, WIND_DIR_SCALE); plot.mapDatasetToScale(WIND_SPEED_DATASET_INDEX, WIND_SPEED_SCALE); plot.mapDatasetToScale(WIND_GUST_DATASET_INDEX, WIND_SPEED_SCALE); plot.mapDatasetToScale(MAX_WIND_SPEED_DATASET_INDEX, WIND_SPEED_SCALE); plot.mapDatasetToScale(MAX_WIND_GUST_DATASET_INDEX, WIND_SPEED_SCALE); StandardDialRange range = new StandardDialRange(0.0, 360.0, Color.BLACK); range.setInnerRadius(.70); range.setOuterRadius(.72); range.setScaleIndex(WIND_DIR_SCALE); plot.addLayer(range); JFreeChart chart = new JFreeChart(plot); chart.setBackgroundPaint(Color.GRAY); chartViewer = new ChartViewer(chart); //chartViewer.setMinHeight(100); //chartViewer.setMinWidth(100); //chartViewer.setMaxHeight(400); //chartViewer.setMaxWidth(400); //chartViewer.setBackground(Color.GRAY); //chartViewer.setBorder(new BevelBorder(BevelBorder.RAISED)); this.setCenter(chartViewer); this.setTop(title); BorderPane.setAlignment(title, Pos.CENTER); title.textProperty().bind(titleProperty); setTitle("Wind"); timeline.setCycleCount(9); timeline.setOnFinished((event) -> { datasets[0].setValue(currentHeading); speedDataset.setValue(currentSpeed); lastHeading = currentHeading; lastSpeed = currentSpeed; }); }
From source file:org.sandsoft.acefx.AceEditor.java
/** * Creates a new instance of the ace editor. * * @return//www .j a v a 2 s . c om * @throws java.io.IOException */ public static AceEditor createNew() throws IOException { //init loader FXMLLoader loader = new FXMLLoader(); loader.setLocation(AceEditor.class.getResource(AceEditor.class.getSimpleName() + ".fxml")); //attach node Node node = (Node) loader.load(); BorderPane.setAlignment(node, Pos.CENTER); AceEditor ace = (AceEditor) loader.getController(); ace.setCenter(node); ace.setMinSize(0, 0); ace.setPrefSize(600, 400); ace.setMaxSize(Double.MAX_VALUE, Double.MAX_VALUE); //post load work ace.initialize(); return ace; }
From source file:org.sandsoft.cymric.util.Commons.java
/** * Create a new custom pane from FXML data. <br> * Restraints: Name and package of FXML file should be the same as * <code>resourceClass</code>. <code>resourceClass</code> should extend * <code>BorderPane</code> or one of its descendents. * * @param resourceClass Pane class in which data to be loaded. * @return Pane type object containing loaded node. *//*from w ww . j a v a 2s . com*/ public static Pane loadPaneFromFXML(Class resourceClass) throws IOException { //init loader FXMLLoader loader = new FXMLLoader(); loader.setLocation(resourceClass.getResource(resourceClass.getSimpleName() + ".fxml")); //load fxml Node node = (Node) loader.load(); BorderPane control = (BorderPane) loader.getController(); BorderPane.setAlignment(node, Pos.CENTER); control.setCenter(node); return control; }
From source file:org.sleuthkit.autopsy.timeline.ui.detailview.AggregateEventNode.java
public AggregateEventNode(final AggregateEvent event, AggregateEventNode parentEventNode, EventDetailChart chart) {//w w w . j a v a2s .c o m this.event = event; descLOD.set(event.getLOD()); this.parentEventNode = parentEventNode; this.chart = chart; final Region region = new Region(); HBox.setHgrow(region, Priority.ALWAYS); final HBox hBox = new HBox(descrLabel, countLabel, region, minusButton, plusButton); hBox.setPrefWidth(USE_COMPUTED_SIZE); hBox.setMinWidth(USE_PREF_SIZE); hBox.setPadding(new Insets(2, 5, 2, 5)); hBox.setAlignment(Pos.CENTER_LEFT); minusButton.setVisible(false); plusButton.setVisible(false); minusButton.setManaged(false); plusButton.setManaged(false); final BorderPane borderPane = new BorderPane(subNodePane, hBox, null, null, null); BorderPane.setAlignment(subNodePane, Pos.TOP_LEFT); borderPane.setPrefWidth(USE_COMPUTED_SIZE); getChildren().addAll(spanRegion, borderPane); setAlignment(Pos.TOP_LEFT); setMinHeight(24); minWidthProperty().bind(spanRegion.widthProperty()); setPrefHeight(USE_COMPUTED_SIZE); setMaxHeight(USE_PREF_SIZE); //set up subnode pane sizing contraints subNodePane.setPrefHeight(USE_COMPUTED_SIZE); subNodePane.setMinHeight(USE_PREF_SIZE); subNodePane.setMinWidth(USE_PREF_SIZE); subNodePane.setMaxHeight(USE_PREF_SIZE); subNodePane.setMaxWidth(USE_PREF_SIZE); subNodePane.setPickOnBounds(false); //setup description label eventTypeImageView.setImage(event.getType().getFXImage()); descrLabel.setGraphic(eventTypeImageView); descrLabel.setPrefWidth(USE_COMPUTED_SIZE); descrLabel.setTextOverrun(OverrunStyle.CENTER_ELLIPSIS); descrLabel.setMouseTransparent(true); setDescriptionVisibility(chart.getDescrVisibility().get()); //setup backgrounds final Color evtColor = event.getType().getColor(); spanFill = new Background( new BackgroundFill(evtColor.deriveColor(0, 1, 1, .1), CORNER_RADII, Insets.EMPTY)); setBackground( new Background(new BackgroundFill(evtColor.deriveColor(0, 1, 1, .1), CORNER_RADII, Insets.EMPTY))); setCursor(Cursor.HAND); spanRegion.setStyle("-fx-border-width:2 0 2 2; -fx-border-radius: 2; -fx-border-color: " + ColorUtilities.getRGBCode(evtColor) + ";"); // NON-NLS spanRegion.setBackground(spanFill); //set up mouse hover effect and tooltip setOnMouseEntered((MouseEvent e) -> { //defer tooltip creation till needed, this had a surprisingly large impact on speed of loading the chart installTooltip(); spanRegion.setEffect(new DropShadow(10, evtColor)); minusButton.setVisible(true); plusButton.setVisible(true); minusButton.setManaged(true); plusButton.setManaged(true); toFront(); }); setOnMouseExited((MouseEvent e) -> { spanRegion.setEffect(null); minusButton.setVisible(false); plusButton.setVisible(false); minusButton.setManaged(false); plusButton.setManaged(false); }); setOnMouseClicked(new EventMouseHandler()); plusButton.disableProperty().bind(descLOD.isEqualTo(DescriptionLOD.FULL)); minusButton.disableProperty().bind(descLOD.isEqualTo(event.getLOD())); plusButton.setOnMouseClicked(e -> { final DescriptionLOD next = descLOD.get().next(); if (next != null) { loadSubClusters(next); descLOD.set(next); } }); minusButton.setOnMouseClicked(e -> { final DescriptionLOD previous = descLOD.get().previous(); if (previous != null) { loadSubClusters(previous); descLOD.set(previous); } }); }