Java Code Examples for javafx.scene.text.TextAlignment#CENTER
The following examples show how to use
javafx.scene.text.TextAlignment#CENTER .
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: StructuredTextRenderer.java From arma-dialog-creator with MIT License | 6 votes |
private static TextAlignment getAlignment(String alignment) { switch (alignment.toLowerCase()) { case "center": { return TextAlignment.CENTER; } case "right": { return TextAlignment.RIGHT; } case "left": { //fallthrough } default: { return TextAlignment.LEFT; } } }
Example 2
Source File: StyledTextField.java From RichTextFX with BSD 2-Clause "Simplified" License | 6 votes |
private double calcHorizontalPos() { double leftPad = getPadding().getLeft(); double rightPad = getPadding().getRight(); double promptWidth = getPlaceholder().getLayoutBounds().getWidth(); TextAlignment alignment = getAlignment(); double alignmentPadding = leftPad; if ( alignment == TextAlignment.RIGHT ) alignmentPadding = rightPad; else if ( alignment == TextAlignment.CENTER ) alignmentPadding = 0; if ( promptWidth < (getWidth() - alignmentPadding) ) setClip( null ); else setClip( new Rectangle( getWidth(), getHeight() ) ); switch ( alignment ) { case CENTER : return (getWidth() - promptWidth) / 2; case RIGHT : return getWidth() - rightPad - promptWidth; default : return leftPad; } }
Example 3
Source File: Timer.java From Quelea with GNU General Public License v3.0 | 5 votes |
private TextAlignment alignmentFromIndex(int index) { switch (index) { case -1: return TextAlignment.LEFT; case 0: return TextAlignment.CENTER; case 1: return TextAlignment.RIGHT; } return TextAlignment.CENTER; }
Example 4
Source File: FxUtils.java From stagedisplayviewer with MIT License | 5 votes |
/** * Converts the String property TextAlignment to the appropriate TextAlignment. * @return */ private TextAlignment getAlignment() { try { return TextAlignment.valueOf(Property.TEXT_ALIGN.toString().toUpperCase()); } catch(IllegalArgumentException e) { log.warn(String.format( "Invalid TEXT_ALIGN property: %s. It should be one of (Case insensitive): Center, Right, Left, or Justify.", Property.TEXT_ALIGN.toString() ), e ); // Default to center align. return TextAlignment.CENTER; } }
Example 5
Source File: Axis.java From charts with Apache License 2.0 | 4 votes |
private void drawTickLabel(final boolean ONLY_FIRST_AND_LAST_VISIBLE, final boolean IS_ZERO, final boolean IS_MIN, final boolean IS_MAX, final boolean FULL_RANGE, final Color ZERO_COLOR, final Color COLOR, final double TEXT_X, final double TEXT_Y, final double MAX_WIDTH, final String TEXT, final Orientation ORIENTATION) { if (!ONLY_FIRST_AND_LAST_VISIBLE) { if (IS_ZERO) { axisCtx.setFill(FULL_RANGE ? ZERO_COLOR : COLOR); } else { axisCtx.setFill(COLOR); } } else { if (IS_MIN || IS_MAX) { if (IS_ZERO) { axisCtx.setFill(FULL_RANGE ? ZERO_COLOR : COLOR); } else { axisCtx.setFill(COLOR); } } else { axisCtx.setFill(Color.TRANSPARENT); } } if (VERTICAL == ORIENTATION) { axisCtx.setTextAlign(TextAlignment.RIGHT); double fontSize = getTitleFontSize(); double textY; if (TEXT_Y < fontSize) { textY = fontSize * 0.5; } else if (TEXT_Y > height - fontSize) { textY = height - fontSize * 0.5; } else { textY = TEXT_Y; } axisCtx.fillText(TEXT, TEXT_X, textY, MAX_WIDTH); } else { if (IS_MIN) { axisCtx.setTextAlign(TextAlignment.LEFT); } else if (IS_MAX) { axisCtx.setTextAlign(TextAlignment.RIGHT); } else { axisCtx.setTextAlign(TextAlignment.CENTER); } double tickLabelWidth = calcTextWidth(tickLabelFont, TEXT); if (axisCtx.getTextAlign() == TextAlignment.CENTER && TEXT_X + tickLabelWidth * 0.5 > width) { axisCtx.fillText(TEXT, width - tickLabelWidth * 0.5, TEXT_Y, MAX_WIDTH); } else { axisCtx.fillText(TEXT, TEXT_X, TEXT_Y, MAX_WIDTH); } } }