本文整理匯總了Java中javafx.scene.text.TextAlignment.CENTER屬性的典型用法代碼示例。如果您正苦於以下問題:Java TextAlignment.CENTER屬性的具體用法?Java TextAlignment.CENTER怎麽用?Java TextAlignment.CENTER使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在類javafx.scene.text.TextAlignment
的用法示例。
在下文中一共展示了TextAlignment.CENTER屬性的4個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: getAlignment
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;
}
}
}
示例2: TileBackground
public TileBackground() {
super.setMinSize(140.6, 136.8);
super.setMaxSize(140.6, 136.8);
super.setTextAlignment(TextAlignment.CENTER);
super.setStyle("-fx-base: grey; " +
"-fx-background-color:linear-gradient(darkslategrey, transparent,darkslategrey);"+
"-fx-background-radius: 8;" +
"-fx-border-radius: 8;"
);
}
示例3: Tile
public Tile() {
super.setMinSize(140.6, 136.8);
super.setMaxSize(140.6, 136.8);
super.setTextAlignment(TextAlignment.CENTER);
super.setAlignment(Pos.CENTER);
}
示例4: drawTickLabel
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);
}
}
}