javafx.geometry.VPos Java Examples

The following examples show how to use javafx.geometry.VPos. 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: Sample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
@Override protected void layoutChildren() {
    if (isFixedSize) {
        super.layoutChildren();
    } else {
        List<Node> managed = getManagedChildren();
        double width = getWidth();
        ///System.out.println("width = " + width);
        double height = getHeight();
        ///System.out.println("height = " + height);
        double top = getInsets().getTop();
        double right = getInsets().getRight();
        double left = getInsets().getLeft();
        double bottom = getInsets().getBottom();
        for (int i = 0; i < managed.size(); i++) {
            Node child = managed.get(i);
            layoutInArea(child, left, top,
                           width - left - right, height - top - bottom,
                           0, Insets.EMPTY, true, true, HPos.CENTER, VPos.CENTER);
        }
    }
}
 
Example #2
Source File: ClockSkin.java    From Enzo with Apache License 2.0 6 votes vote down vote up
private void drawLogoLayer() {
    ctx.clearRect(0, 0, size, size);
    if (Clock.Design.BOSCH == getSkinnable().getDesign()) {
        ctx.setFill(getSkinnable().isNightMode() ? Color.rgb(240, 240, 240) : Color.rgb(10, 10, 10));
        ctx.fillRect(size * 0.5 - 1, size * 0.18, 2, size * 0.27);
        ctx.fillRect(size * 0.5 - 1, size * 0.55, 2, size * 0.27);
        ctx.fillRect(size * 0.18, size * 0.5 - 1, size * 0.27, 2);
        ctx.fillRect(size * 0.55, size * 0.5 - 1, size * 0.27, 2);
    }
    if (getSkinnable().getText().isEmpty()) return;
    ctx.setFill(getSkinnable().isNightMode() ? Color.WHITE : Color.BLACK);
    ctx.setFont(Fonts.opensansSemiBold(size * 0.05));
    ctx.setTextBaseline(VPos.CENTER);
    ctx.setTextAlign(TextAlignment.CENTER);        
    ctx.fillText(getSkinnable().getText(), size * 0.5, size * 0.675, size * 0.8);
}
 
Example #3
Source File: StreamChart.java    From charts with Apache License 2.0 6 votes vote down vote up
private void resize() {
    width         = getWidth() - getInsets().getLeft() - getInsets().getRight();
    height        = getHeight() - getInsets().getTop() - getInsets().getBottom();
    reducedHeight = height - height * 0.05;
    size          = width < height ? width : height;

    if (width > 0 && height > 0) {
        canvas.setWidth(width);
        canvas.setHeight(height);
        canvas.relocate((getWidth() - width) * 0.5, (getHeight() - height) * 0.5);

        ctx.setTextBaseline(VPos.CENTER);
        ctx.setFont(Font.font(Helper.clamp(8, 24, size * 0.025)));

        groupBy(getCategory());
    }
}
 
Example #4
Source File: TextElement.java    From PDF4Teachers with Apache License 2.0 6 votes vote down vote up
public TextElement(int x, int y, int pageNumber, Font font, String text, Color color, boolean hasPage){
	super(x, y, pageNumber);

	this.text.setFont(font);
	this.text.setFill(color);
	this.text.setText(text);

	this.text.setBoundsType(TextBoundsType.LOGICAL);
	this.text.setTextOrigin(VPos.TOP);

	if(hasPage && getPage() != null){
		setupGeneral(isLaTeX() ? this.image : this.text);
		updateLaTeX();
	}

}
 
Example #5
Source File: BarChartItem.java    From OEE-Designer with MIT License 6 votes vote down vote up
private void initGraphics() {
    if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 ||
        Double.compare(getWidth(), 0.0) <= 0 || Double.compare(getHeight(), 0.0) <= 0) {
        if (getPrefWidth() > 0 && getPrefHeight() > 0) {
            setPrefSize(getPrefWidth(), getPrefHeight());
        } else {
            setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    nameText = new Text(getName());
    nameText.setTextOrigin(VPos.TOP);

    valueText = new Text(String.format(locale, formatString, getValue()));
    valueText.setTextOrigin(VPos.TOP);

    barBackground = new Rectangle();

    bar = new Rectangle();

    pane = new Pane(nameText, valueText, barBackground, bar);
    pane.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));

    getChildren().setAll(pane);
}
 
Example #6
Source File: LegendItem.java    From charts with Apache License 2.0 6 votes vote down vote up
private void initGraphics() {
    if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0 || Double.compare(getWidth(), 0.0) <= 0 ||
        Double.compare(getHeight(), 0.0) <= 0) {
        if (getPrefWidth() > 0 && getPrefHeight() > 0) {
            setPrefSize(getPrefWidth(), getPrefHeight());
        } else {
            setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT);
        }
    }

    canvas = new Canvas(PREFERRED_HEIGHT, PREFERRED_HEIGHT);
    ctx    = canvas.getGraphicsContext2D();
    ctx.setTextAlign(TextAlignment.LEFT);
    ctx.setTextBaseline(VPos.CENTER);

    pane   = new Pane(canvas);

    getChildren().setAll(pane);
}
 
Example #7
Source File: DonutChartTileSkin.java    From tilesfx with Apache License 2.0 6 votes vote down vote up
private void drawLegend() {
    List<ChartData> dataList     = tile.getChartData();
    double          canvasWidth  = legendCanvas.getWidth();
    double          canvasHeight = legendCanvas.getHeight();
    int             noOfItems    = dataList.size();
    Color           textColor    = tile.getTextColor();
    double          stepSize     = canvasHeight * 0.9 / (noOfItems + 1);

    legendCtx.clearRect(0, 0, canvasWidth, canvasHeight);
    legendCtx.setTextAlign(TextAlignment.LEFT);
    legendCtx.setTextBaseline(VPos.CENTER);
    legendCtx.setFont(Fonts.latoRegular(canvasHeight * 0.05));

    for (int i = 0 ; i < noOfItems ; i++) {
        ChartData data = dataList.get(i);

        legendCtx.setFill(data.getFillColor());
        legendCtx.fillOval(0, (i + 1) * stepSize, size * 0.0375, size * 0.0375);
        legendCtx.setFill(textColor);
        legendCtx.fillText(data.getName(), size * 0.05, (i + 1) * stepSize + canvasHeight * 0.025);
    }
}
 
Example #8
Source File: StringBindingSample.java    From marathonv5 with Apache License 2.0 6 votes vote down vote up
public static Node createIconContent() {
    Text text = new Text("abc");
    text.setTextOrigin(VPos.TOP);
    text.setLayoutX(10);
    text.setLayoutY(11);
    text.setFill(Color.BLACK);
    text.setOpacity(0.5);
    text.setFont(Font.font(null, FontWeight.BOLD, 20));
    text.setStyle("-fx-font-size: 20px;");

    Text text2 = new Text("abc");
    text2.setTextOrigin(VPos.TOP);
    text2.setLayoutX(28);
    text2.setLayoutY(51);
    text2.setFill(Color.BLACK);
    text2.setFont(javafx.scene.text.Font.font(null, FontWeight.BOLD, 20));
    text2.setStyle("-fx-font-size: 20px;");
            
    Line line = new Line(30, 32, 45, 57);
    line.setStroke(Color.DARKMAGENTA);

    return new javafx.scene.Group(text, line, text2);
}
 
Example #9
Source File: GaugeTileSkin.java    From OEE-Designer with MIT License 6 votes vote down vote up
@Override protected void resizeDynamicText() {
    double maxWidth = unitText.isManaged() ? width - size * 0.275 : width - size * 0.1;
    double fontSize = size * 0.24;
    valueText.setFont(Fonts.latoRegular(fontSize));
    if (valueText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(valueText, maxWidth, fontSize); }

    fontSize = size * 0.1;
    unitText.setFont(Fonts.latoRegular(fontSize));
    if (unitText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(unitText, maxWidth, fontSize); }

    thresholdText.setFill(sectionsVisible ? Color.TRANSPARENT : tile.getBackgroundColor());
    if (!sectionsVisible) {
        fontSize = size * 0.08;
        thresholdText.setFont(Fonts.latoRegular(fontSize));
        thresholdText.setTextOrigin(VPos.CENTER);
        if (thresholdText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(thresholdText, maxWidth, fontSize); }
        thresholdText.setX((width - thresholdText.getLayoutBounds().getWidth()) * 0.5);
        thresholdText.setY(thresholdRect.getLayoutBounds().getMinY() + thresholdRect.getHeight() * 0.5);
    }
}
 
Example #10
Source File: JFXDrawersStack.java    From JFoenix with Apache License 2.0 6 votes vote down vote up
@Override
protected void layoutChildren() {
    performingLayout = true;
    List<Node> managed = getManagedChildren();
    final double width = getWidth();
    double height = getHeight();
    double top = getInsets().getTop();
    double right = getInsets().getRight();
    double left = getInsets().getLeft();
    double bottom = getInsets().getBottom();
    double contentWidth = width - left - right;
    double contentHeight = height - top - bottom;
    for (int i = 0, size = managed.size(); i < size; i++) {
        Node child = managed.get(i);
        layoutInArea(child, left, top, contentWidth, contentHeight,
            0, Insets.EMPTY,
            HPos.CENTER, VPos.CENTER);
    }
    performingLayout = false;
}
 
Example #11
Source File: CFileChooser.java    From Open-Lowcode with Eclipse Public License 2.0 6 votes vote down vote up
@Override
public Node getNode(
		PageActionManager actionmanager,
		CPageData inputdata,
		Window parentwindow,
		TabPane[] parenttabpanes,
		CollapsibleNode nodetocollapsewhenactiontriggered) {

	FlowPane thispane = new FlowPane();
	Label thislabel = new Label(title);
	thislabel.setFont(Font.font(thislabel.getFont().getName(), FontPosture.ITALIC, thislabel.getFont().getSize()));
	thislabel.setMinWidth(120);
	thislabel.setWrapText(true);
	thislabel.setMaxWidth(120);
	thispane.setRowValignment(VPos.TOP);
	thispane.getChildren().add(thislabel);

	filepathfield = new TextField();
	Button loadfromfile = new Button("Select");
	loadfromfile.setStyle("-fx-base: #ffffff; -fx-hover-base: #ddeeff;");
	thispane.getChildren().add(filepathfield);
	thispane.getChildren().add(loadfromfile);
	loadfromfile.setOnAction(new EventHandler<ActionEvent>() {

		@Override
		public void handle(ActionEvent arg0) {
			FileChooser fileChooser = new FileChooser();
			selectedfile = fileChooser.showOpenDialog(null);
			if (selectedfile != null)
				filepathfield.setText(selectedfile.getAbsolutePath());
		}
	});

	return thispane;
}
 
Example #12
Source File: BottomSlidePane.java    From markdown-writer-fx with BSD 2-Clause "Simplified" License 6 votes vote down vote up
@Override
protected void layoutChildren() {
	double width = getWidth();
	double height = getHeight();

	Node center = getCenter();
	Node bottom = getBottom();

	double bottomHeight = 0;
	if (bottom != null) {
		double bottomPrefHeight = bottom.prefHeight(-1);
		bottomHeight = bottomPrefHeight * bottomVisibility.get();

		layoutInArea(bottom, 0, height - bottomHeight, width, bottomPrefHeight, 0, HPos.LEFT, VPos.BOTTOM);
	}

	if (center != null)
		layoutInArea(center, 0, 0, width, height - bottomHeight, 0, HPos.CENTER, VPos.CENTER);
}
 
Example #13
Source File: GraphicsContextImpl.java    From openchemlib-js with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
@Override
public void drawText(String s, double x, double y, boolean centerHorz, boolean centerVert)
{
    ctx.setTextAlign(centerHorz ? TextAlignment.CENTER : TextAlignment.LEFT);
    ctx.setTextBaseline(centerVert ? VPos.CENTER : VPos.TOP);
    ctx.strokeText(s, x, y);

}
 
Example #14
Source File: FormPane.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public FormPane addFormField(String text, Node field, int colSpan, int rowSpan) {
    Label label = new Label(text);
    String labelId = idText(text);
    label.setId(labelId);
    GridPane.setValignment(label, VPos.TOP);
    int column = 0;
    add(label, column++, currentRow, 1, 1);
    field.setId(labelId + "-field-1");
    setFormConstraints(field);
    GridPane.setValignment(field, VPos.TOP);
    add(field, column++, currentRow, colSpan, rowSpan);
    currentRow += rowSpan;
    column = 0;
    return this;
}
 
Example #15
Source File: CustomNodeSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
public static Node createIconContent() {
    MyEnsembleNode myNode = new MyEnsembleNode("MyNode");
    myNode.setLayoutY(50);
    MyEnsembleNode parent = new MyEnsembleNode("Parent");
    Polygon arrow = createUMLArrow();
    arrow.setLayoutY(20);
    arrow.setLayoutX(25-7.5);
    Text text = new Text("<<extends>>");
    text.setTextOrigin(VPos.TOP);
    text.setLayoutY(31);
    text.setLayoutX(30);
    return new Group(parent, arrow, text, myNode);
}
 
Example #16
Source File: Helper.java    From charts with Apache License 2.0 5 votes vote down vote up
public static final void drawTextWithBackground(final GraphicsContext CTX, final String TEXT, final Font FONT, final Color TEXT_BACKGROUND, final Color TEXT_FILL, final double X, final double Y) {
    CtxDimension dim = getTextDimension(TEXT, FONT);
    double textWidth  = dim.getWidth() * 1.2;
    double textHeight = dim.getHeight();
    CTX.save();
    CTX.setFont(FONT);
    CTX.setTextBaseline(VPos.CENTER);
    CTX.setTextAlign(TextAlignment.CENTER);
    CTX.setFill(TEXT_BACKGROUND);
    CTX.fillRect(X - textWidth * 0.5, Y - textHeight * 0.5, textWidth, textHeight);
    CTX.setFill(TEXT_FILL);
    CTX.fillText(TEXT, X, Y);
    CTX.restore();
}
 
Example #17
Source File: SegmentedEdgeViewer.java    From JetUML with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Draws a string.
 * @param pGraphics the graphics context
 * @param pEndPoint1 an endpoint of the segment along which to draw the string
 * @param pEndPoint2 the other endpoint of the segment along which to draw the string
 * @param pString the string to draw 
 * @param pCenter true if the string should be centered along the segment
 */
private static void drawString(GraphicsContext pGraphics, Point2D pEndPoint1, Point2D pEndPoint2, 
		ArrowHead pArrowHead, String pString, boolean pCenter)
{
	if (pString == null || pString.length() == 0)
	{
		return;
	}
	Rectangle bounds = getStringBounds(pEndPoint1, pEndPoint2, pArrowHead, pString, pCenter);
	
	Paint oldFill = pGraphics.getFill();
	VPos oldVPos = pGraphics.getTextBaseline();
	TextAlignment oldAlign = pGraphics.getTextAlign();
	pGraphics.translate(bounds.getX(), bounds.getY());
	pGraphics.setFill(Color.BLACK);
	int textX = 0;
	int textY = 0;
	if(pCenter) 
	{
		textX = bounds.getWidth()/2;
		textY = bounds.getHeight() - textDimensions(pString).getHeight()/2;
		pGraphics.setTextBaseline(VPos.CENTER);
		pGraphics.setTextAlign(TextAlignment.CENTER);
	}
	pGraphics.fillText(pString, textX, textY);
	pGraphics.translate(-bounds.getX(), -bounds.getY()); 
	pGraphics.setFill(oldFill);
	pGraphics.setTextBaseline(oldVPos);
	pGraphics.setTextAlign(oldAlign);
}
 
Example #18
Source File: AbstractValueIndicator.java    From chart-fx with Apache License 2.0 5 votes vote down vote up
/**
 * Layouts the label within specified bounds and given horizontal and vertical position, taking into account
 * {@link #labelHorizontalAnchorProperty() horizontal} and {@link #labelVerticalAnchorProperty() vertical} anchor.
 *
 * @param bounds the bounding rectangle with respect to which the label should be positioned
 * @param hPos relative [0, 1] horizontal position of the label within the bounds
 * @param vPos relative [0, 1] vertical position of the label within the bounds
 */
protected final void layoutLabel(final Bounds bounds, final double hPos, final double vPos) {
    if (label.getText() == null || label.getText().isEmpty()) {
        getChartChildren().remove(label);
        return;
    }

    double xPos = bounds.getMinX();
    double yPos = bounds.getMinY();

    xOffset = bounds.getWidth() * hPos;
    yOffset = bounds.getHeight() * (1 - vPos);

    final double width = label.prefWidth(-1);
    final double height = label.prefHeight(width);

    if (getLabelHorizontalAnchor() == HPos.CENTER) {
        xOffset -= width / 2;
    } else if (getLabelHorizontalAnchor() == HPos.RIGHT) {
        xOffset -= width;
    }

    if (getLabelVerticalAnchor() == VPos.CENTER) {
        yOffset -= height / 2;
    } else if (getLabelVerticalAnchor() == VPos.BASELINE) {
        yOffset -= label.getBaselineOffset();
    } else if (getLabelVerticalAnchor() == VPos.BOTTOM) {
        yOffset -= height;
    }

    label.resizeRelocate(xPos + xOffset, yPos + yOffset, width, height);
    addChildNodeIfNotPresent(label);
}
 
Example #19
Source File: LeaderBoardItem.java    From OEE-Designer with MIT License 5 votes vote down vote up
private void initGraphics() {
	if (Double.compare(getPrefWidth(), 0.0) <= 0 || Double.compare(getPrefHeight(), 0.0) <= 0
			|| Double.compare(getWidth(), 0.0) <= 0 || Double.compare(getHeight(), 0.0) <= 0) {
		if (getPrefWidth() > 0 && getPrefHeight() > 0) {
			setPrefSize(getPrefWidth(), getPrefHeight());
		} else {
			setPrefSize(PREFERRED_WIDTH, PREFERRED_HEIGHT); // 11x7
		}
	}

	state = State.CONSTANT;

	triangle = new Path();
	triangle.setStroke(null);
	triangle.setFill(state.color);
	triangle.setRotate(state.angle);

	nameText = new Text(getName());
	nameText.setTextOrigin(VPos.TOP);

	valueText = new Text(String.format(locale, formatString, getValue()));
	valueText.setTextOrigin(VPos.TOP);

	separator = new Line();

	pane = new Pane(triangle, nameText, valueText, separator);
	pane.setBackground(new Background(new BackgroundFill(Color.TRANSPARENT, CornerRadii.EMPTY, Insets.EMPTY)));

	getChildren().setAll(pane);
}
 
Example #20
Source File: PushButtonSkin.java    From Enzo with Apache License 2.0 5 votes vote down vote up
private void initGraphics() {
    frame = new Region();
    frame.getStyleClass().setAll("frame");

    outerBorder = new Region();
    outerBorder.getStyleClass().setAll("outer-border");

    innerBorder = new Region();
    innerBorder.getStyleClass().setAll("inner-border");

    body = new Region();
    body.getStyleClass().setAll("body");
    body.setMouseTransparent(true);

    text = new Text("Push");
    text.setTextOrigin(VPos.CENTER);
    text.setMouseTransparent(true);
    text.getStyleClass().setAll("text");

    pane.getChildren().setAll(frame,
                              outerBorder,
                              innerBorder,
                              body,
                              text);

    getChildren().setAll(pane);
    resize();
}
 
Example #21
Source File: ShortcutInformationPanelSkin.java    From phoenicis with GNU Lesser General Public License v3.0 5 votes vote down vote up
/**
 * Updates the shortcutProperties of the shortcut in the given {@link GridPane propertiesGrid}
 *
 * @param propertiesGrid The shortcutProperties grid
 */
private void updateProperties(final GridPane propertiesGrid) {
    propertiesGrid.getChildren().clear();

    for (Map.Entry<String, Object> entry : shortcutProperties.entrySet()) {
        final int row = propertiesGrid.getRowCount();

        if (!entry.getKey().equals("environment")) {
            final Label keyLabel = new Label(tr(decamelize(entry.getKey())) + ":");
            keyLabel.getStyleClass().add("captionTitle");
            GridPane.setValignment(keyLabel, VPos.TOP);

            final Label valueLabel = new Label(entry.getValue().toString());
            valueLabel.setWrapText(true);

            propertiesGrid.addRow(row, keyLabel, valueLabel);
        }
    }

    // set the environment
    this.environmentAttributes.clear();

    if (shortcutProperties.containsKey("environment")) {
        final Map<String, String> environment = (Map<String, String>) shortcutProperties.get("environment");

        this.environmentAttributes.putAll(environment);
    }
}
 
Example #22
Source File: NumberTileSkin.java    From OEE-Designer with MIT License 5 votes vote down vote up
@Override protected void initGraphics() {
    super.initGraphics();

    titleText = new Text();
    titleText.setFill(tile.getTitleColor());
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());

    text = new Text(tile.getText());
    text.setFill(tile.getUnitColor());
    Helper.enableNode(text, tile.isTextVisible());

    valueText = new Text(String.format(locale, formatString, ((tile.getValue() - minValue) / range * 100)));
    valueText.setFill(tile.getValueColor());
    valueText.setTextOrigin(VPos.BASELINE);
    Helper.enableNode(valueText, tile.isValueVisible());

    unitText = new Text(" " + tile.getUnit());
    unitText.setFill(tile.getUnitColor());
    unitText.setTextOrigin(VPos.BASELINE);
    Helper.enableNode(unitText, !tile.getUnit().isEmpty());

    valueUnitFlow = new TextFlow(valueText, unitText);
    valueUnitFlow.setTextAlignment(TextAlignment.RIGHT);

    description = new Label(tile.getText());
    description.setAlignment(tile.getDescriptionAlignment());
    description.setWrapText(true);
    description.setTextFill(tile.getTextColor());
    Helper.enableNode(description, tile.isTextVisible());

    getPane().getChildren().addAll(titleText, text, valueUnitFlow, description);
}
 
Example #23
Source File: ClockTileSkin.java    From tilesfx with Apache License 2.0 5 votes vote down vote up
@Override protected void initGraphics() {
    super.initGraphics();

    currentValueListener = o -> {
        if (tile.isRunning()) { return; } // Update time only if clock is not already running
        updateTime(ZonedDateTime.ofInstant(Instant.ofEpochSecond(tile.getCurrentTime()), ZoneId.of(ZoneId.systemDefault().getId())));
    };
    timeListener         = o -> updateTime(tile.getTime());

    timeFormatter      = DateTimeFormatter.ofPattern("HH:mm", tile.getLocale());
    dateFormatter      = DateTimeFormatter.ofPattern("dd MMM YYYY", tile.getLocale());
    dayOfWeekFormatter = DateTimeFormatter.ofPattern("EEEE", tile.getLocale());

    titleText = new Text("");
    titleText.setTextOrigin(VPos.TOP);
    Helper.enableNode(titleText, !tile.getTitle().isEmpty());

    text = new Text(tile.getText());
    text.setFill(tile.getUnitColor());
    Helper.enableNode(text, tile.isTextVisible());

    timeRect = new Rectangle();

    timeText = new Text(timeFormatter.format(tile.getTime()));
    timeText.setTextOrigin(VPos.CENTER);

    dateText = new Text(dateFormatter.format(tile.getTime()));

    dayOfWeekText = new Text(dayOfWeekFormatter.format(tile.getTime()));

    getPane().getChildren().addAll(titleText, text, timeRect, timeText, dateText, dayOfWeekText);
}
 
Example #24
Source File: BigDecimalFieldSkin.java    From robovm-samples with Apache License 2.0 5 votes vote down vote up
@Override
protected void layoutChildren(double contentX, double contentY, double contentWidth, double contentHeight) {
    super.layoutChildren(contentX, contentY, contentWidth, contentHeight); //To change body of generated methods, choose Tools | Templates.
    Insets insets = getSkinnable().getInsets();
    double x = insets.getLeft();
    double y = insets.getTop();
    double textfieldHeight = contentHeight;
    double buttonWidth = textField.prefHeight(-1);
    Insets buttonInsets = btnDown.getInsets();
    double textfieldWidth = this.getSkinnable().getWidth()-insets.getLeft()-insets.getRight() - buttonWidth - buttonInsets.getLeft() - buttonInsets.getRight();
    layoutInArea(textField, x, y, textfieldWidth, textfieldHeight, Control.USE_PREF_SIZE, HPos.LEFT, VPos.TOP);
    layoutInArea(btnUp, x+textfieldWidth+buttonInsets.getLeft(), y, buttonWidth, textfieldHeight/2, Control.USE_PREF_SIZE, HPos.LEFT, VPos.TOP);
    layoutInArea(btnDown, x+textfieldWidth+buttonInsets.getLeft(), y+textfieldHeight/2, buttonWidth, textfieldHeight/2, Control.USE_PREF_SIZE, HPos.LEFT, VPos.TOP);
}
 
Example #25
Source File: Properties.java    From phoebus with Eclipse Public License 1.0 5 votes vote down vote up
private void setCommand(final TreeItem<ScanCommand> tree_item)
{
    final GridPane prop_grid = new GridPane();
    prop_grid.setPadding(new Insets(5));
    prop_grid.setHgap(5);
    prop_grid.setVgap(5);

    if (tree_item != null)
    {
        int row = 0;
        for (ScanCommandProperty prop : tree_item.getValue().getProperties())
        {
            final Label label = new Label(prop.getName());
            prop_grid.add(label, 0, row);

            try
            {
                final Node editor = createEditor(tree_item, prop);
                GridPane.setHgrow(editor, Priority.ALWAYS);
                GridPane.setFillWidth(editor, true);

                // Label defaults to vertical center,
                // which is good for one-line editors.
                if (editor instanceof StringArrayEditor)
                    GridPane.setValignment(label, VPos.TOP);

                prop_grid.add(editor, 1, row++);
            }
            catch (Exception ex)
            {
                logger.log(Level.WARNING, "Cannot create editor for " + prop, ex);
            }
            ++row;
        }
    }

    scroll.setContent(prop_grid);
}
 
Example #26
Source File: OnOffSwitchSkin.java    From Enzo with Apache License 2.0 5 votes vote down vote up
private void resize() {
    width  = getSkinnable().getWidth();
    height = getSkinnable().getHeight();

    if (width > 0 && height > 0) {
        if (aspectRatio * width > height) {
            width = 1 / (aspectRatio / height);
        } else if (1 / (aspectRatio / height) > width) {
            height = aspectRatio * width;
        }

        font = Font.font("Open Sans", FontWeight.EXTRA_BOLD, FontPosture.REGULAR, 0.5 * height);

        background.setPrefSize(width, height);

        selectedText.setFont(font);
        selectedText.setTextOrigin(VPos.CENTER);
        selectedText.relocate(height * 0.3125, (height - selectedText.getLayoutBounds().getHeight()) * 0.5);

        deselectedText.setFont(font);
        deselectedText.setTextOrigin(VPos.CENTER);
        deselectedText.relocate(width - height * 0.3125 - deselectedText.getLayoutBounds().getWidth(), (height - deselectedText.getLayoutBounds().getHeight()) * 0.5);

        thumb.setPrefSize((height * 0.75), (height * 0.75));
        thumb.setTranslateX(getSkinnable().isSelected() ? height * 1.125 : height * 0.125);
        thumb.setTranslateY(height * 0.125);

        moveToDeselected.setFromX(height * 1.125);
        moveToDeselected.setToX(height * 0.125);

        moveToSelected.setFromX(height * 0.125);
        moveToSelected.setToX(height * 1.125);
    }
}
 
Example #27
Source File: Toast.java    From DevToolBox with GNU Lesser General Public License v2.1 5 votes vote down vote up
public void show(Node anchor, Side side, double offsetX, double offsetY) {
    if (anchor == null) {
        return;
    }
    autoCenter = false;

    HPos hpos = side == Side.LEFT ? HPos.LEFT : side == Side.RIGHT ? HPos.RIGHT : HPos.CENTER;
    VPos vpos = side == Side.TOP ? VPos.TOP : side == Side.BOTTOM ? VPos.BOTTOM : VPos.CENTER;
    // translate from anchor/hpos/vpos/offsetX/offsetY into screenX/screenY
    Point2D point = Utils.pointRelativeTo(anchor, content.prefWidth(-1), content.prefHeight(-1), hpos, vpos, offsetX, offsetY, true);
    this.show(anchor, point.getX(), point.getY());
}
 
Example #28
Source File: MutableOfferView.java    From bisq with GNU Affero General Public License v3.0 5 votes vote down vote up
private void addPayInfoEntry(GridPane infoGridPane, int row, String labelText, String value) {
    Label label = new AutoTooltipLabel(labelText);
    TextField textField = new TextField(value);
    textField.setMinWidth(500);
    textField.setEditable(false);
    textField.setFocusTraversable(false);
    textField.setId("payment-info");
    GridPane.setConstraints(label, 0, row, 1, 1, HPos.RIGHT, VPos.CENTER);
    GridPane.setConstraints(textField, 1, row);
    infoGridPane.getChildren().addAll(label, textField);
}
 
Example #29
Source File: WebViewBrowser.java    From netbeans with Apache License 2.0 5 votes vote down vote up
public WebViewPane() {
    VBox.setVgrow(this, Priority.ALWAYS);
    setMaxWidth(Double.MAX_VALUE);
    setMaxHeight(Double.MAX_VALUE);

    WebView view = new WebView();
    view.setMinSize(500, 400);
    view.setPrefSize(500, 400);
    final WebEngine eng = view.getEngine();
    eng.load("http://www.oracle.com/us/index.html");
    final TextField locationField = new TextField("http://www.oracle.com/us/index.html");
    locationField.setMaxHeight(Double.MAX_VALUE);
    Button goButton = new Button("Go");
    goButton.setDefaultButton(true);
    EventHandler<ActionEvent> goAction = new EventHandler<ActionEvent>() {
        @Override public void handle(ActionEvent event) {
            eng.load(locationField.getText().startsWith("http://") ? locationField.getText() :
                    "http://" + locationField.getText());
        }
    };
    goButton.setOnAction(goAction);
    locationField.setOnAction(goAction);
    eng.locationProperty().addListener(new ChangeListener<String>() {
        @Override public void changed(ObservableValue<? extends String> observable, String oldValue, String newValue) {
            locationField.setText(newValue);
        }
    });
    GridPane grid = new GridPane();
    grid.setVgap(5);
    grid.setHgap(5);
    GridPane.setConstraints(locationField, 0, 0, 1, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.SOMETIMES);
    GridPane.setConstraints(goButton,1,0);
    GridPane.setConstraints(view, 0, 1, 2, 1, HPos.CENTER, VPos.CENTER, Priority.ALWAYS, Priority.ALWAYS);
    grid.getColumnConstraints().addAll(
            new ColumnConstraints(100, 100, Double.MAX_VALUE, Priority.ALWAYS, HPos.CENTER, true),
            new ColumnConstraints(40, 40, 40, Priority.NEVER, HPos.CENTER, true)
    );
    grid.getChildren().addAll(locationField, goButton, view);
    getChildren().add(grid);
}
 
Example #30
Source File: DeckView.java    From Solitaire with GNU General Public License v2.0 5 votes vote down vote up
private Canvas createNewGameImage()
{
	double width = CardImages.getBack().getWidth();
	double height = CardImages.getBack().getHeight();
	Canvas canvas = new Canvas( width, height );
	GraphicsContext context = canvas.getGraphicsContext2D();
	
	// The reset image
	context.setStroke(Color.DARKGREEN);
	context.setLineWidth(IMAGE_NEW_LINE_WIDTH);
	context.strokeOval(width/4, height/2-width/4 + IMAGE_FONT_SIZE, width/2, width/2);

	// The text
	
	context.setTextAlign(TextAlignment.CENTER);
	context.setTextBaseline(VPos.CENTER);
	context.setFill(Color.DARKKHAKI);
	context.setFont(Font.font(Font.getDefault().getName(), IMAGE_FONT_SIZE));
	
	
	
	if( GameModel.instance().isCompleted() )
	{
		context.fillText("You won!", Math.round(width/2), IMAGE_FONT_SIZE);
	}
	else
	{
		context.fillText("Give up?", Math.round(width/2), IMAGE_FONT_SIZE);
	}
	context.setTextAlign(TextAlignment.CENTER);
	return canvas;
}