javafx.scene.text.TextBoundsType Java Examples

The following examples show how to use javafx.scene.text.TextBoundsType. 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: FXStockToken.java    From Rails with GNU General Public License v2.0 6 votes vote down vote up
private void populate() {
    // fill the background
    Circle circle = new Circle();

    circle.centerXProperty().bind(Bindings.divide(widthProperty(), 2));
    circle.centerYProperty().bind(Bindings.divide(heightProperty(), 2));
    circle.radiusProperty().bind(Bindings.divide(widthProperty(), 2));

    circle.setFill(backgroundColor);

    Text text = new Text(name);

    text.setStroke(foregroundColor);
    text.setBoundsType(TextBoundsType.VISUAL);

    getChildren().addAll(circle, text);
}
 
Example #2
Source File: StringViewer.java    From JetUML with GNU General Public License v3.0 6 votes vote down vote up
private Text getLabel(String pString)
{
	Text label = new Text();
	if (aUnderlined)
	{
		label.setUnderline(true);
	}
	label.setFont(getFont());
	label.setBoundsType(TextBoundsType.VISUAL);
	label.setText(pString);
	
	if(aAlignment == Align.LEFT)
	{
		label.setTextAlignment(TextAlignment.LEFT);
	}
	else if(aAlignment == Align.CENTER)
	{
		label.setTextAlignment(TextAlignment.CENTER);
	}
	else if(aAlignment == Align.RIGHT) 
	{
		label.setTextAlignment(TextAlignment.RIGHT);
	}
	return label;
}
 
Example #3
Source File: FridayFunSkin.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
private Text createCenteredText(double cx, double cy, String styleClass) {
  Text text = new Text();
  text.getStyleClass().add(styleClass);
  text.setTextOrigin(VPos.CENTER);
  text.setTextAlignment(TextAlignment.CENTER);
  double width = cx > ARTBOARD_SIZE * 0.5 ? ((ARTBOARD_SIZE - cx) * 2.0) : cx * 2.0;
  text.setWrappingWidth(width);
  text.setBoundsType(TextBoundsType.VISUAL);
  text.setY(cy);
  text.setX(cx - (width / 2.0));

  return text;
}
 
Example #4
Source File: LinearSkin.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
@Override
public void initializeParts() {
  value = new Text(0, ARTBOARD_HEIGHT * 0.5, String.format(FORMAT, getSkinnable().getValue()));
  value.getStyleClass().add("value");
  value.setTextOrigin(VPos.CENTER);
  value.setTextAlignment(TextAlignment.CENTER);
  value.setMouseTransparent(true);
  value.setWrappingWidth(ARTBOARD_HEIGHT);
  value.setBoundsType(TextBoundsType.VISUAL);

  thumb = new Circle(ARTBOARD_HEIGHT * 0.5, ARTBOARD_HEIGHT * 0.5, ARTBOARD_HEIGHT * 0.5);
  thumb.getStyleClass().add("thumb");

  thumbGroup = new Group(thumb, value);

  valueBar = new Line();
  valueBar.getStyleClass().add("valueBar");
  valueBar.setStrokeLineCap(StrokeLineCap.ROUND);
  applyCss(valueBar);
  strokeWidthFromCSS = valueBar.getStrokeWidth();

  scale = new Line();
  scale.getStyleClass().add("scale");
  scale.setStrokeLineCap(StrokeLineCap.ROUND);

  // always needed
  drawingPane = new Pane();
}
 
Example #5
Source File: SlimSkin.java    From WorkbenchFX with Apache License 2.0 5 votes vote down vote up
private Text createCenteredText(double cx, double cy, String styleClass) {
  Text text = new Text();
  text.getStyleClass().add(styleClass);
  text.setTextOrigin(VPos.CENTER);
  text.setTextAlignment(TextAlignment.CENTER);
  double width = cx > ARTBOARD_WIDTH * 0.5 ? ((ARTBOARD_WIDTH - cx) * 2.0) : cx * 2.0;
  text.setWrappingWidth(width);
  text.setBoundsType(TextBoundsType.VISUAL);
  text.setY(cy);

  return text;
}
 
Example #6
Source File: StopWatchSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private void configureName(String string) {
    Font font = new Font(9);
    name.setText(string);
    name.setBoundsType(TextBoundsType.VISUAL);
    name.setLayoutX(-name.getBoundsInLocal().getWidth() / 2 + 4.8);
    name.setLayoutY(radius * 1 / 2 + 4);
    name.setFill(FILL_COLOR);
    name.setFont(font);
}
 
Example #7
Source File: StopWatchSample.java    From marathonv5 with Apache License 2.0 5 votes vote down vote up
private void configureName(String string) {
    Font font = new Font(9);
    name.setText(string);
    name.setBoundsType(TextBoundsType.VISUAL);
    name.setLayoutX(-name.getBoundsInLocal().getWidth() / 2 + 4.8);
    name.setLayoutY(radius * 1 / 2 + 4);
    name.setFill(FILL_COLOR);
    name.setFont(font);
}
 
Example #8
Source File: StopWatch.java    From netbeans with Apache License 2.0 5 votes vote down vote up
private void configureName(String string) {
    Font font = new Font(9);
    name.setText(string);
    name.setBoundsType(TextBoundsType.VISUAL);
    name.setLayoutX(-name.getBoundsInLocal().getWidth() / 2 + 4.8);
    name.setLayoutY(radius * 1 / 2 + 4);
    name.setFill(FILL_COLOR);
    name.setFont(font);
}
 
Example #9
Source File: TextDetailPaneInfo.java    From scenic-view with GNU General Public License v3.0 4 votes vote down vote up
@Override protected void updateDetail(final String propertyName) {
    final boolean all = propertyName.equals("*") ? true : false;

    final Text textnode = (Text) getTarget();
    if (all || propertyName.equals("content")) {
        contentDetail.setValue(textnode != null ? "\"" + textnode.getText() + "\"" : "-");
        contentDetail.setIsDefault(textnode == null || textnode.getText() == null);
        contentDetail.setSimpleProperty((textnode != null) ? textnode.textProperty() : null);
        if (!all)
            contentDetail.updated();
        if (!all)
            return;
    }
    if (all || propertyName.equals("font")) {
        fontDetail.setValue(textnode != null ? textnode.getFont().getName() : "-");
        fontDetail.setIsDefault(textnode == null);
        if (!all)
            fontDetail.updated();
        if (!all)
            return;
    }
    if (all || propertyName.equals("textOrigin")) {
        originDetail.setValue(textnode != null ? textnode.getTextOrigin().toString() : "-");
        originDetail.setIsDefault(textnode == null);
        originDetail.setEnumProperty(textnode != null ? textnode.textOriginProperty() : null, VPos.class);
        if (!all)
            originDetail.updated();
        if (!all)
            return;
    }
    if (all || propertyName.equals("x") || propertyName.equals("y")) {
        xyDetail.setValue(textnode != null ? f.format(textnode.getX()) + " , " + f.format(textnode.getY()) : "-");
        xyDetail.setIsDefault(textnode == null || (textnode.getX() == 0 && textnode.getY() == 0));
        xyDetail.setSimpleSizeProperty(textnode != null ? textnode.xProperty() : null, textnode != null ? textnode.yProperty() : null);
        if (!all)
            xyDetail.updated();
        if (!all)
            return;
    }
    if (all || propertyName.equals("textAlignment")) {
        alignmentDetail.setValue(textnode != null ? textnode.getTextAlignment().toString() : "-");
        alignmentDetail.setIsDefault(textnode == null);
        alignmentDetail.setEnumProperty(textnode != null ? textnode.textAlignmentProperty() : null, TextAlignment.class);
        if (!all)
            alignmentDetail.updated();
        if (!all)
            return;
    }
    if (all || propertyName.equals("textBoundsType")) {
        boundsTypeDetail.setValue(textnode != null ? textnode.getBoundsType().toString() : "-");
        boundsTypeDetail.setIsDefault(textnode == null || textnode.getBoundsType() == TextBoundsType.LOGICAL);
        boundsTypeDetail.setEnumProperty(textnode != null ? textnode.boundsTypeProperty() : null, TextBoundsType.class);
        if (!all)
            boundsTypeDetail.updated();
        if (!all)
            return;
    }
    if (all || propertyName.equals("wrappingWidth")) {
        wrappingWidthDetail.setValue(textnode != null ? f.format(textnode.getWrappingWidth()) : "-");
        wrappingWidthDetail.setIsDefault(textnode == null || textnode.getWrappingWidth() == 0);
        wrappingWidthDetail.setSimpleProperty((textnode != null) ? textnode.wrappingWidthProperty() : null);
        if (!all)
            wrappingWidthDetail.updated();
        if (!all)
            return;
    }
    if (all || propertyName.equals("underline")) {
        underlineDetail.setValue(textnode != null ? Boolean.toString(textnode.isUnderline()) : "-");
        underlineDetail.setIsDefault(textnode == null || !textnode.isUnderline());
        underlineDetail.setSimpleProperty(textnode != null ? textnode.underlineProperty() : null);
        if (!all)
            underlineDetail.updated();
        if (!all)
            return;
    }
    if (all || propertyName.equals("strikethrough")) {
        strikethroughDetail.setValue(textnode != null ? Boolean.toString(textnode.isStrikethrough()) : "-");
        strikethroughDetail.setIsDefault(textnode == null || !textnode.isStrikethrough());
        strikethroughDetail.setSimpleProperty(textnode != null ? textnode.strikethroughProperty() : null);
        if (!all)
            strikethroughDetail.updated();
    }
    if (all)
        sendAllDetails();
}
 
Example #10
Source File: StockTileSkin.java    From OEE-Designer with MIT License 4 votes vote down vote up
@Override protected void initGraphics() {
    super.initGraphics();

    averagingListener = o -> handleEvents("AVERAGING_PERIOD");

    timeFormatter = DateTimeFormatter.ofPattern("HH:mm", tile.getLocale());

    state = State.CONSTANT;

    if (tile.isAutoScale()) tile.calcAutoScale();

    low            = tile.getMaxValue();
    high           = tile.getMinValue();
    movingAverage  = tile.getMovingAverage();
    noOfDatapoints = tile.getAveragingPeriod();
    dataList       = new LinkedList<>();

    // To get smooth lines in the chart we need at least 4 values
    if (noOfDatapoints < 4) throw new IllegalArgumentException("Please increase the averaging period to a value larger than 3.");

    graphBounds = new Rectangle(PREFERRED_WIDTH * 0.05, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.45);

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

    valueText = new Text(String.format(locale, formatString, tile.getValue()));
    valueText.setBoundsType(TextBoundsType.VISUAL);
    valueText.setFill(tile.getValueColor());
    Helper.enableNode(valueText, tile.isValueVisible());

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

    highText = new Text();
    highText.setTextOrigin(VPos.BOTTOM);
    highText.setFill(tile.getValueColor());

    lowText = new Text();
    lowText.setTextOrigin(VPos.TOP);
    lowText.setFill(tile.getValueColor());

    text = new Text(tile.getText());
    text.setTextOrigin(VPos.TOP);
    text.setFill(tile.getTextColor());

    timeSpanText = new Text("");
    timeSpanText.setTextOrigin(VPos.TOP);
    timeSpanText.setFill(tile.getTextColor());
    Helper.enableNode(timeSpanText, !tile.isTextVisible());

    referenceLine = new Line();
    referenceLine.getStrokeDashArray().addAll(3d, 3d);
    referenceLine.setVisible(false);

    pathElements = new ArrayList<>(noOfDatapoints);
    pathElements.add(0, new MoveTo());
    for (int i = 1 ; i < noOfDatapoints ; i++) { pathElements.add(i, new LineTo()); }

    sparkLine = new Path();
    sparkLine.getElements().addAll(pathElements);
    sparkLine.setFill(null);
    sparkLine.setStroke(tile.getBarColor());
    sparkLine.setStrokeWidth(PREFERRED_WIDTH * 0.0075);
    sparkLine.setStrokeLineCap(StrokeLineCap.ROUND);
    sparkLine.setStrokeLineJoin(StrokeLineJoin.ROUND);

    dot = new Circle();
    dot.setFill(tile.getBarColor());
    dot.setVisible(false);

    triangle = new Path();
    triangle.setStroke(null);
    triangle.setFill(state.color);
    indicatorPane = new StackPane(triangle);

    changeText = new Label(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", (tile.getCurrentValue() - tile.getReferenceValue())));
    changeText.setTextFill(state.color);
    changeText.setAlignment(Pos.CENTER_RIGHT);

    changePercentageText = new Text(new StringBuilder().append(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", (tile.getCurrentValue() / tile.getReferenceValue() * 100.0) - 100.0)).append("\u0025").toString());
    changePercentageText.setFill(state.color);

    changePercentageFlow = new TextFlow(indicatorPane, changePercentageText);
    changePercentageFlow.setTextAlignment(TextAlignment.RIGHT);

    getPane().getChildren().addAll(titleText, valueUnitFlow, sparkLine, dot, referenceLine, highText, lowText, timeSpanText, text, changeText, changePercentageFlow);
}
 
Example #11
Source File: StockTileSkin.java    From tilesfx with Apache License 2.0 4 votes vote down vote up
@Override protected void initGraphics() {
    super.initGraphics();

    averagingListener = o -> handleEvents("AVERAGING_PERIOD");

    timeFormatter = DateTimeFormatter.ofPattern("HH:mm", tile.getLocale());

    state = State.CONSTANT;

    if (tile.isAutoScale()) tile.calcAutoScale();

    low            = tile.getMaxValue();
    high           = tile.getMinValue();
    movingAverage  = tile.getMovingAverage();
    noOfDatapoints = tile.getAveragingPeriod();
    dataList       = new LinkedList<>();

    // To get smooth lines in the chart we need at least 4 values
    if (noOfDatapoints < 4) throw new IllegalArgumentException("Please increase the averaging period to a value larger than 3.");

    graphBounds = new Rectangle(PREFERRED_WIDTH * 0.05, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.45);

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

    valueText = new Text(String.format(locale, formatString, tile.getValue()));
    valueText.setBoundsType(TextBoundsType.VISUAL);
    valueText.setFill(tile.getValueColor());
    Helper.enableNode(valueText, tile.isValueVisible());

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

    highText = new Text();
    highText.setTextOrigin(VPos.BOTTOM);
    highText.setFill(tile.getValueColor());

    lowText = new Text();
    lowText.setTextOrigin(VPos.TOP);
    lowText.setFill(tile.getValueColor());

    text = new Text(tile.getText());
    text.setTextOrigin(VPos.TOP);
    text.setFill(tile.getTextColor());

    timeSpanText = new Text("");
    timeSpanText.setTextOrigin(VPos.TOP);
    timeSpanText.setFill(tile.getTextColor());
    Helper.enableNode(timeSpanText, !tile.isTextVisible());

    referenceLine = new Line();
    referenceLine.getStrokeDashArray().addAll(3d, 3d);
    referenceLine.setVisible(false);

    pathElements = new ArrayList<>(noOfDatapoints);
    pathElements.add(0, new MoveTo());
    for (int i = 1 ; i < noOfDatapoints ; i++) { pathElements.add(i, new LineTo()); }

    sparkLine = new Path();
    sparkLine.getElements().addAll(pathElements);
    sparkLine.setFill(null);
    sparkLine.setStroke(tile.getBarColor());
    sparkLine.setStrokeWidth(PREFERRED_WIDTH * 0.0075);
    sparkLine.setStrokeLineCap(StrokeLineCap.ROUND);
    sparkLine.setStrokeLineJoin(StrokeLineJoin.ROUND);

    dot = new Circle();
    dot.setFill(tile.getBarColor());
    dot.setVisible(false);

    triangle = new Path();
    triangle.setStroke(null);
    triangle.setFill(state.color);
    indicatorPane = new StackPane(triangle);

    changeText = new Label(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", (tile.getCurrentValue() - tile.getReferenceValue())));
    changeText.setTextFill(state.color);
    changeText.setAlignment(Pos.CENTER_RIGHT);

    changePercentageText = new Text(new StringBuilder().append(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", (tile.getCurrentValue() / tile.getReferenceValue() * 100.0) - 100.0)).append(Helper.PERCENTAGE).toString());
    changePercentageText.setFill(state.color);

    changePercentageFlow = new TextFlow(indicatorPane, changePercentageText);
    changePercentageFlow.setTextAlignment(TextAlignment.RIGHT);

    getPane().getChildren().addAll(titleText, valueUnitFlow, sparkLine, dot, referenceLine, highText, lowText, timeSpanText, text, changeText, changePercentageFlow);
}