Java Code Examples for javafx.scene.text.Text#prefHeight()
The following examples show how to use
javafx.scene.text.Text#prefHeight() .
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: AbstractAxis.java From chart-fx with Apache License 2.0 | 5 votes |
/** * Computes the preferred height of this axis for the given width. If axis orientation is horizontal, it takes into * account the tick mark length, tick label gap and label height. * * @return the computed preferred width for this axis */ @Override protected double computePrefHeight(final double width) { final Side side = getSide(); if ((side == null) || (side == Side.CENTER_HOR) || side.isVertical()) { // default axis size for uninitalised axis return 150; } if (getTickMarks().isEmpty()) { final AxisRange range = autoRange(width); computeTickMarks(range, true); invalidate(); } // we need to first auto range as this may/will effect tick marks // final AxisRange range = autoRange(width); // calculate max tick label height // calculate the new tick mark label height final double maxLabelHeightLocal = isTickLabelsVisible() ? maxLabelHeight : 0.0; // if (isTickLabelsVisible()) { // // final List<TickMark> tempMajorTickMarks = computeTickMarks(range, // // true); // final List<TickMark> tempMajorTickMarks = this.getTickMarks(); // maxLabelHeight = getMaxTickLabelHeight(tempMajorTickMarks) + // getTickLabelGap(); // } // calculate tick mark length final double tickMarkLength = isTickMarkVisible() && (getTickLength() > 0) ? getTickLength() : 0; // calculate label height final Text axisLabel = getAxisLabel(); final String axisLabelText = axisLabel.getText(); final double labelHeight = (axisLabelText == null) || axisLabelText.isEmpty() ? 0 : axisLabel.prefHeight(-1) + (2 * getAxisLabelGap()); final double shiftedLabels = ((getOverlapPolicy() == AxisLabelOverlapPolicy.SHIFT_ALT) && isLabelOverlapping()) || (getOverlapPolicy() == AxisLabelOverlapPolicy.FORCED_SHIFT_ALT) ? labelHeight : 0.0; return tickMarkLength + maxLabelHeightLocal + labelHeight + shiftedLabels; }
Example 2
Source File: AbstractAxis.java From chart-fx with Apache License 2.0 | 5 votes |
/** * Computes the preferred width of this axis for the given height. If axis orientation is vertical, it takes into * account the tick mark length, tick label gap and label height. * * @return the computed preferred width for this axis */ @Override protected double computePrefWidth(final double height) { final Side side = getSide(); if ((side == null) || (side == Side.CENTER_VER) || side.isHorizontal()) { // default axis size for uninitalised axis return 150; } if (getTickMarks().isEmpty()) { final AxisRange range = autoRange(height); computeTickMarks(range, true); invalidate(); } // we need to first auto range as this may/will effect tick marks // final AxisRange range = autoRange(height); // calculate max tick label width final double maxLabelWidthLocal = isTickLabelsVisible() ? maxLabelWidth : 0.0; // calculate the new tick mark label width // if (isTickLabelsVisible()) { // // final List<TickMark> tempMajorTickMarks = computeTickMarks(range, // // true); // final List<TickMark> tempMajorTickMarks = this.getTickMarks(); // maxLabelWidth = getMaxTickLabelWidth(tempMajorTickMarks) + // getTickLabelGap(); // } // calculate tick mark length final double tickMarkLength = isTickMarkVisible() && (getTickLength() > 0) ? getTickLength() : 0; // calculate label height final Text axisLabel = getAxisLabel(); final String axisLabelText = axisLabel.getText(); final double labelHeight = (axisLabelText == null) || axisLabelText.isEmpty() ? 0 : axisLabel.prefHeight(-1) + (2 * getAxisLabelGap()); final double shiftedLabels = ((getOverlapPolicy() == AxisLabelOverlapPolicy.SHIFT_ALT) && isLabelOverlapping()) || (getOverlapPolicy() == AxisLabelOverlapPolicy.FORCED_SHIFT_ALT) ? labelHeight : 0.0; return maxLabelWidthLocal + tickMarkLength + labelHeight + shiftedLabels; }
Example 3
Source File: UserView.java From NLIDB with Apache License 2.0 | 4 votes |
@Override public void start(Stage primaryStage) throws Exception { stage = primaryStage; stage.setTitle("Window for NLIDB"); Label label1 = new Label("Welcome to Natural Language Interface to DataBase!"); Label lblInput = new Label("Natural Language Input:"); TextArea fieldIn = new TextArea(); fieldIn.setPrefHeight(100); fieldIn.setPrefWidth(100); fieldIn.setWrapText(true); fieldIn.setText(TEST_TEXT); btnTranslate = new Button("translate"); // Define action of the translate button. btnTranslate.setOnAction(e -> { ctrl.processNaturalLanguage(fieldIn.getText()); }); display = new Text(); display.setWrappingWidth(500); display.prefHeight(300); display.setText("Default display text"); // choices and button for nodes mapping choiceBox = new ComboBox<NodeInfo>(); choiceBox.setVisibleRowCount(6); btnConfirmChoice = new Button("confirm choice"); btnConfirmChoice.setOnAction(e -> { ctrl.chooseNode(getChoice()); }); // choices and button for tree selection treeChoice = new ComboBox<Integer>(); // ! only show 3 choices now treeChoice.setItems(FXCollections.observableArrayList(0,1,2)); treeChoice.getSelectionModel().selectedIndexProperty().addListener((ov, oldV, newV) -> { ctrl.showTree(treeChoice.getItems().get((Integer) newV)); }); btnTreeConfirm = new Button("confirm tree choice"); btnTreeConfirm.setOnAction(e -> { ctrl.chooseTree(treeChoice.getValue()); }); vb1 = new VBox(); vb1.setSpacing(10); vb1.getChildren().addAll( label1, lblInput,fieldIn, btnTranslate ); vb2 = new VBox(); vb2.setSpacing(20); vb2.getChildren().addAll(display); hb = new HBox(); hb.setPadding(new Insets(15, 12, 15, 12)); hb.setSpacing(10); hb.getChildren().addAll(vb1, vb2); scene = new Scene(hb, 800, 450); stage.setScene(scene); ctrl = new Controller(this); stage.show(); }