Java Code Examples for javafx.scene.text.TextFlow#setTextAlignment()
The following examples show how to use
javafx.scene.text.TextFlow#setTextAlignment() .
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: News.java From pdfsam with GNU Affero General Public License v3.0 | 6 votes |
News(NewsData data) { this.getStyleClass().add("news-box"); TextFlow flow = new TextFlow(); if (data.isImportant()) { Text megaphone = FontAwesomeIconFactory.get().createIcon(FontAwesomeIcon.BULLHORN, "1.2em"); megaphone.getStyleClass().clear(); megaphone.getStyleClass().add("news-box-title-important"); flow.getChildren().addAll(megaphone, new Text(" ")); } Text titleText = new Text(data.getTitle() + System.lineSeparator()); titleText.setOnMouseClicked(e -> eventStudio().broadcast(new OpenUrlRequest(data.getLink()))); titleText.getStyleClass().add("news-box-title"); Text contentText = new Text(data.getContent()); contentText.setTextAlignment(TextAlignment.JUSTIFY); contentText.getStyleClass().add("news-content"); flow.getChildren().addAll(titleText, contentText); flow.setTextAlignment(TextAlignment.JUSTIFY); Label labelDate = new Label(FORMATTER.format(data.getDate()), MaterialDesignIconFactory.get().createIcon(MaterialDesignIcon.CLOCK)); labelDate.setPrefWidth(Integer.MAX_VALUE); HBox.setHgrow(labelDate, Priority.ALWAYS); HBox bottom = new HBox(labelDate); bottom.setAlignment(Pos.CENTER_LEFT); bottom.getStyleClass().add("news-box-footer"); if (isNotBlank(data.getLink())) { Button link = UrlButton.urlButton(null, data.getLink(), FontAwesomeIcon.EXTERNAL_LINK_SQUARE, "pdfsam-toolbar-button"); bottom.getChildren().add(link); } getChildren().addAll(flow, bottom); }
Example 2
Source File: CreateFilePane.java From pattypan with MIT License | 6 votes |
private void showOpenFileButton() { Hyperlink link = new Hyperlink(Util.text("create-file-open")); TextFlow flow = new TextFlow(new WikiLabel("create-file-success"), link); flow.setTextAlignment(TextAlignment.CENTER); addElement(flow); link.setOnAction(ev -> { try { Desktop.getDesktop().open(Session.FILE); } catch (IOException ex) { Session.LOGGER.log(Level.WARNING, "Cannot open file: {0}", new String[]{ex.getLocalizedMessage()} ); } }); nextButton.linkTo("StartPane", stage, true).setText(Util.text("create-file-back-to-start")); nextButton.setVisible(true); }
Example 3
Source File: LoginPane.java From pattypan with MIT License | 6 votes |
private void setContent() { TextFlow flow = new TextFlow(new Text(Util.text("login-intro")), link); flow.setTextAlignment(TextAlignment.CENTER); addElement(flow); addElement(loginText); addElement(passwordText); addElement(loginButton); addElement(loginStatus); if (!Settings.getSetting("user").isEmpty()) { loginText.setText(Settings.getSetting("user")); Platform.runLater(() -> { passwordText.requestFocus(); }); } }
Example 4
Source File: ClientLoginNode.java From helloiot with GNU General Public License v3.0 | 6 votes |
@Override public void updateItem(TopicInfo item, boolean empty) { super.updateItem(item, empty); if (item == null) { setGraphic(null); setText(null); } else { Text t = IconBuilder.create(item.getFactory().getGlyph(), 18.0).build(); t.setFill(Color.WHITE); TextFlow tf = new TextFlow(t); tf.setTextAlignment(TextAlignment.CENTER); tf.setPadding(new Insets(5, 5, 5, 5)); tf.setStyle("-fx-background-color: #505050; -fx-background-radius: 5px;"); tf.setPrefWidth(30.0); setGraphic(tf); String label = item.getLabel().getValue(); setText(item.getFactory().getTypeName() + ((label == null || label.isEmpty()) ? "" : " : " + label)); } }
Example 5
Source File: TopicsTemplate.java From helloiot with GNU General Public License v3.0 | 6 votes |
@Override public void updateItem(TemplateInfo item, boolean empty) { super.updateItem(item, empty); if (item == null) { setGraphic(null); setText(null); } else { Text t = IconBuilder.create(IconFontGlyph.valueOf(item.icon), 18.0).build(); t.setFill(Color.WHITE); TextFlow tf = new TextFlow(t); tf.setTextAlignment(TextAlignment.CENTER); tf.setPadding(new Insets(5, 5, 5, 5)); tf.setStyle("-fx-background-color: #505050; -fx-background-radius: 5px;"); tf.setPrefWidth(30.0); setGraphic(tf); setText(item.name); } }
Example 6
Source File: TopicsGallery.java From helloiot with GNU General Public License v3.0 | 6 votes |
@Override public void updateItem(TopicInfoFactory item, boolean empty) { super.updateItem(item, empty); if (item == null) { setGraphic(null); setText(null); } else { Text t = IconBuilder.create(item.getGlyph(), 18.0).build(); t.setFill(Color.WHITE); TextFlow tf = new TextFlow(t); tf.setTextAlignment(TextAlignment.CENTER); tf.setPadding(new Insets(5, 5, 5, 5)); tf.setStyle("-fx-background-color: #505050; -fx-background-radius: 5px;"); tf.setPrefWidth(30.0); setGraphic(tf); setText(item.getTypeName()); } }
Example 7
Source File: TimeTileSkin.java From OEE-Designer with MIT License | 5 votes |
@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()); LocalTime duration = tile.getDuration(); leftText = new Text(Integer.toString(duration.getHour() > 0 ? duration.getHour() : duration.getMinute())); leftText.setFill(tile.getValueColor()); leftUnit = new Text(duration.getHour() > 0 ? "h" : "m"); leftUnit.setFill(tile.getValueColor()); rightText = new Text(Integer.toString(duration.getHour() > 0 ? duration.getMinute() : duration.getSecond())); rightText.setFill(tile.getValueColor()); rightUnit = new Text(duration.getHour() > 0 ? "m" : "s"); rightUnit.setFill(tile.getValueColor()); timeText = new TextFlow(leftText, leftUnit, rightText, rightUnit); timeText.setTextAlignment(TextAlignment.RIGHT); timeText.setPrefWidth(PREFERRED_WIDTH * 0.9); description = new Label(tile.getDescription()); description.setAlignment(Pos.TOP_RIGHT); description.setWrapText(true); description.setTextFill(tile.getTextColor()); Helper.enableNode(description, !tile.getDescription().isEmpty()); getPane().getChildren().addAll(titleText, text, timeText, description); }
Example 8
Source File: StartPane.java From pattypan with MIT License | 5 votes |
private GridPane setContent() { this.getStylesheets().add(css); this.setAlignment(Pos.CENTER); this.setHgap(20); this.setVgap(5); this.getStyleClass().add("background"); this.getColumnConstraints().add(Util.newColumn(400, "px")); this.addRow(0, new WikiLabel("pattypan").setClass("title")); this.addRow(1, new WikiLabel("v. " + Settings.VERSION)); if (!Session.WIKI.getDomain().equals("commons.wikimedia.org")) { this.addRow(3, new WikiLabel(Session.WIKI.getDomain())); } this.addRow(20, new HBox(20, new WikiButton("start-generate-button", "primary") .setWidth(300) .linkTo("ChooseDirectoryPane", stage), new WikiButton("start-validate-button") .setWidth(300) .linkTo("LoadPane", stage))); this.addRow(22, new HBox(20, new WikiLabel("start-generate-description").setWidth(300), new WikiLabel("start-validate-description").setWidth(300))); String year = new SimpleDateFormat("yyyy").format(new Date()); this.addRow(40, new WikiLabel(year + " // Pawel Marynowski").setClass("muted")); TextFlow flow = new TextFlow( new Text(Util.text("start-bug-found")), bugLink, new Text(" • "), logFile); flow.setTextAlignment(TextAlignment.CENTER); this.addRow(41, flow); return this; }
Example 9
Source File: NumberTileSkin.java From OEE-Designer with MIT License | 5 votes |
@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 10
Source File: TimeTileSkin.java From tilesfx with Apache License 2.0 | 5 votes |
@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()); LocalTime duration = tile.getDuration(); leftText = new Text(Integer.toString(duration.getHour() > 0 ? duration.getHour() : duration.getMinute())); leftText.setFill(tile.getValueColor()); leftUnit = new Text(duration.getHour() > 0 ? "h" : "m"); leftUnit.setFill(tile.getValueColor()); rightText = new Text(Integer.toString(duration.getHour() > 0 ? duration.getMinute() : duration.getSecond())); rightText.setFill(tile.getValueColor()); rightUnit = new Text(duration.getHour() > 0 ? "m" : "s"); rightUnit.setFill(tile.getValueColor()); timeText = new TextFlow(leftText, leftUnit, rightText, rightUnit); timeText.setTextAlignment(TextAlignment.RIGHT); timeText.setPrefWidth(PREFERRED_WIDTH * 0.9); description = new Label(tile.getDescription()); description.setAlignment(Pos.TOP_RIGHT); description.setWrapText(true); description.setTextFill(tile.getDescriptionColor()); Helper.enableNode(description, !tile.getDescription().isEmpty()); getPane().getChildren().addAll(titleText, text, timeText, description); }
Example 11
Source File: Gauge2TileSkin.java From tilesfx with Apache License 2.0 | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); angleRange = tile.getAngleRange(); angleStep = tile.getAngleStep(); if (tile.isAutoScale()) tile.calcAutoScale(); oldValue = tile.getValue(); barBackgroundColor = tile.getBarBackgroundColor(); gradientLookup = new GradientLookup(tile.getGradientStops()); knob = new Circle(); barBackground = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.696, PREFERRED_WIDTH * 0.275, PREFERRED_WIDTH * 0.275, angleRange * 0.5 + 90, -angleRange); barBackground.setType(ArcType.OPEN); barBackground.setStroke(barBackgroundColor); barBackground.setStrokeWidth(PREFERRED_WIDTH * 0.02819549 * 2); barBackground.setStrokeLineCap(StrokeLineCap.ROUND); barBackground.setFill(null); bar = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.696, PREFERRED_WIDTH * 0.275, PREFERRED_WIDTH * 0.275, angleRange * 0.5 + 90, 0); bar.setType(ArcType.OPEN); bar.setStrokeWidth(PREFERRED_WIDTH * 0.02819549 * 2); bar.setStrokeLineCap(StrokeLineCap.ROUND); bar.setFill(null); barBounds = new Rectangle(); createConicalGradient(); needleRotate = new Rotate((tile.getValue() - oldValue - minValue) * angleStep); needleRectRotate = new Rotate((tile.getValue() - oldValue - minValue) * angleStep); needle = new Path(); needle.setFillRule(FillRule.EVEN_ODD); needle.getTransforms().setAll(needleRotate); needle.setFill(tile.getNeedleColor()); needle.setStrokeWidth(0); needle.setStroke(Color.TRANSPARENT); titleText = new Text(tile.getTitle()); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); valueText = new Text(String.format(locale, formatString, tile.getCurrentValue())); valueText.setFill(tile.getValueColor()); Helper.enableNode(valueText, tile.isValueVisible() && !tile.isAlert()); unitText = new Text(tile.getUnit()); unitText.setFill(tile.getUnitColor()); Helper.enableNode(unitText, !tile.getUnit().isEmpty()); valueUnitFlow = new TextFlow(valueText, unitText); valueUnitFlow.setTextAlignment(TextAlignment.CENTER); minValueText = new Text(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", tile.getMinValue())); minValueText.setFill(tile.getTitleColor()); minValueText.setTextOrigin(VPos.CENTER); maxValueText = new Text(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", tile.getMaxValue())); maxValueText.setFill(tile.getTitleColor()); maxValueText.setTextOrigin(VPos.CENTER); text = new Text(tile.getText()); text.setTextOrigin(VPos.TOP); text.setFill(tile.getTextColor()); getPane().getChildren().addAll(knob, barBackground, bar, needle, titleText, valueUnitFlow, minValueText, maxValueText, text); }
Example 12
Source File: CountdownTimerTileSkin.java From tilesfx with Apache License 2.0 | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); duration = tile.getTimePeriod(); minValue = 0; maxValue = duration.getSeconds(); range = duration.getSeconds(); angleStep = ANGLE_RANGE / range; locale = tile.getLocale(); titleText = new Text(); titleText.setFill(tile.getTitleColor()); enableNode(titleText, !tile.getTitle().isEmpty()); text = new Text(tile.getText()); text.setFill(tile.getTextColor()); enableNode(text, tile.isTextVisible()); barBackground = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.468, PREFERRED_HEIGHT * 0.468, 90, 360); barBackground.setType(ArcType.OPEN); barBackground.setStroke(tile.getBarBackgroundColor()); barBackground.setStrokeWidth(PREFERRED_WIDTH * 0.1); barBackground.setStrokeLineCap(StrokeLineCap.BUTT); barBackground.setFill(null); bar = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.5, PREFERRED_WIDTH * 0.468, PREFERRED_HEIGHT * 0.468, 90, 0); bar.setType(ArcType.OPEN); bar.setStroke(tile.getBarColor()); bar.setStrokeWidth(PREFERRED_WIDTH * 0.1); bar.setStrokeLineCap(StrokeLineCap.BUTT); bar.setFill(null); separator = new Line(PREFERRED_WIDTH * 0.5, 1, PREFERRED_WIDTH * 0.5, 0.16667 * PREFERRED_HEIGHT); separator.setStroke(tile.getBackgroundColor()); separator.setFill(Color.TRANSPARENT); durationText = new Text(); durationText.setFont(Fonts.latoRegular(PREFERRED_WIDTH * 0.27333)); durationText.setFill(tile.getValueColor()); durationText.setTextOrigin(VPos.CENTER); durationFlow = new TextFlow(durationText); durationFlow.setTextAlignment(TextAlignment.CENTER); timeText = new Text(DTF.format(LocalTime.now().plus(tile.getTimePeriod().getSeconds(), ChronoUnit.SECONDS))); timeText.setFont(Fonts.latoRegular(PREFERRED_WIDTH * 0.27333)); timeText.setFill(tile.getValueColor()); timeText.setTextOrigin(VPos.CENTER); enableNode(timeText, tile.isValueVisible()); timeFlow = new TextFlow(timeText); timeFlow.setTextAlignment(TextAlignment.CENTER); runningListener = (o, ov, nv) -> { if (nv) { timeText.setText(DTF.format(LocalTime.now().plus(duration.getSeconds(), ChronoUnit.SECONDS))); } }; timeListener = e -> { if (TimeEventType.SECOND == e.TYPE) { updateBar(); } }; getPane().getChildren().addAll(barBackground, bar, separator, titleText, text, durationFlow, timeFlow); }
Example 13
Source File: StockTileSkin.java From tilesfx with Apache License 2.0 | 4 votes |
@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); }
Example 14
Source File: HighLowTileSkin.java From tilesfx with Apache License 2.0 | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); oldValue = tile.getValue(); double deviation = calculateDeviation(); updateState(deviation); titleText = new Text(); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); text = new Text(tile.getUnit()); text.setFill(tile.getUnitColor()); Helper.enableNode(text, tile.isTextVisible()); valueText = new Text(String.format(locale, formatString, tile.getValue())); valueText.setFill(tile.getValueColor()); Helper.enableNode(valueText, tile.isValueVisible()); upperUnitText = new Text(""); upperUnitText.setFill(tile.getUnitColor()); Helper.enableNode(upperUnitText, !tile.getUnit().isEmpty()); fractionLine = new Line(); unitText = new Text(tile.getUnit()); unitText.setFill(tile.getUnitColor()); Helper.enableNode(unitText, !tile.getUnit().isEmpty()); unitFlow = new VBox(upperUnitText, unitText); unitFlow.setAlignment(Pos.CENTER_RIGHT); valueUnitFlow = new HBox(valueText, unitFlow); valueUnitFlow.setAlignment(Pos.BOTTOM_RIGHT); valueUnitFlow.setMouseTransparent(true); description = new Label(tile.getDescription()); description.setAlignment(tile.getDescriptionAlignment()); description.setWrapText(true); description.setTextFill(tile.getTextColor()); Helper.enableNode(description, !tile.getDescription().isEmpty()); triangle = new Path(); triangle.setStroke(null); triangle.setFill(state.color); indicatorPane = new StackPane(triangle); deviationText = new Text(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", deviation)); deviationText.setFill(state.color); deviationUnitText = new Text("%"); deviationUnitText.setFill(Tile.FOREGROUND); referenceUnitFlow = new TextFlow(indicatorPane, deviationText, deviationUnitText); referenceUnitFlow.setTextAlignment(TextAlignment.LEFT); getPane().getChildren().addAll(titleText, text, valueUnitFlow, fractionLine, description, referenceUnitFlow); //handleCurrentValue(tile.getValue()); }
Example 15
Source File: GaugeTileSkin.java From OEE-Designer with MIT License | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); if (tile.isAutoScale()) tile.calcAutoScale(); oldValue = tile.getValue(); sectionMap = new HashMap<>(sections.size()); for(Section section : sections) { sectionMap.put(section, new Arc()); } barColor = tile.getBarColor(); thresholdColor = tile.getThresholdColor(); barBackground = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.696, PREFERRED_WIDTH * 0.275, PREFERRED_WIDTH * 0.275, angleRange * 0.5 + 90, -angleRange); barBackground.setType(ArcType.OPEN); barBackground.setStroke(barColor); barBackground.setStrokeWidth(PREFERRED_WIDTH * 0.02819549 * 2); barBackground.setStrokeLineCap(StrokeLineCap.BUTT); barBackground.setFill(null); thresholdBar = new Arc(PREFERRED_WIDTH * 0.5, PREFERRED_HEIGHT * 0.696, PREFERRED_WIDTH * 0.275, PREFERRED_WIDTH * 0.275, -angleRange * 0.5 + 90, 0); thresholdBar.setType(ArcType.OPEN); thresholdBar.setStroke(tile.getThresholdColor()); thresholdBar.setStrokeWidth(PREFERRED_WIDTH * 0.02819549 * 2); thresholdBar.setStrokeLineCap(StrokeLineCap.BUTT); thresholdBar.setFill(null); Helper.enableNode(thresholdBar, !tile.getSectionsVisible()); sectionPane = new Pane(); Helper.enableNode(sectionPane, tile.getSectionsVisible()); if (sectionsVisible) { drawSections(); } alertIcon = new Path(); alertIcon.setFillRule(FillRule.EVEN_ODD); alertIcon.setFill(Color.YELLOW); alertIcon.setStroke(null); Helper.enableNode(alertIcon, tile.isAlert()); alertTooltip = new Tooltip(tile.getAlertMessage()); Tooltip.install(alertIcon, alertTooltip); needleRotate = new Rotate((tile.getValue() - oldValue - minValue) * angleStep); needleRectRotate = new Rotate((tile.getValue() - oldValue - minValue) * angleStep); needleRect = new Rectangle(); needleRect.setFill(tile.getBackgroundColor()); needleRect.getTransforms().setAll(needleRectRotate); needle = new Path(); needle.setFillRule(FillRule.EVEN_ODD); needle.getTransforms().setAll(needleRotate); needle.setFill(tile.getNeedleColor()); needle.setStrokeWidth(0); needle.setStroke(Color.TRANSPARENT); titleText = new Text(tile.getTitle()); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); valueText = new Text(String.format(locale, formatString, tile.getCurrentValue())); valueText.setFill(tile.getValueColor()); valueText.setTextOrigin(VPos.BASELINE); Helper.enableNode(valueText, tile.isValueVisible() && !tile.isAlert()); unitText = new Text(tile.getUnit()); unitText.setFill(tile.getUnitColor()); unitText.setTextOrigin(VPos.BASELINE); Helper.enableNode(unitText, tile.isValueVisible() && !tile.isAlert()); valueUnitFlow = new TextFlow(valueText, unitText); valueUnitFlow.setTextAlignment(TextAlignment.CENTER); minValueText = new Text(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", tile.getMinValue())); minValueText.setFill(tile.getTitleColor()); maxValueText = new Text(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", tile.getMaxValue())); maxValueText.setFill(tile.getTitleColor()); thresholdRect = new Rectangle(); thresholdRect.setFill(sectionsVisible ? Color.TRANSPARENT : tile.getValue() > tile.getThreshold() ? tile.getThresholdColor() : Tile.GRAY); Helper.enableNode(thresholdRect, tile.isThresholdVisible()); thresholdText = new Text(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", tile.getThreshold())); thresholdText.setFill(sectionsVisible ? Color.TRANSPARENT : Tile.GRAY); Helper.enableNode(thresholdText, tile.isThresholdVisible()); getPane().getChildren().addAll(barBackground, thresholdBar, sectionPane, alertIcon, needleRect, needle, titleText, valueUnitFlow, minValueText, maxValueText, thresholdRect, thresholdText); }
Example 16
Source File: StockTileSkin.java From OEE-Designer with MIT License | 4 votes |
@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 17
Source File: HighLowTileSkin.java From OEE-Designer with MIT License | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); oldValue = tile.getValue(); double deviation = calculateDeviation(); updateState(deviation); titleText = new Text(); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); text = new Text(tile.getUnit()); text.setFill(tile.getUnitColor()); Helper.enableNode(text, tile.isTextVisible()); valueText = new Text(String.format(locale, formatString, tile.getValue())); valueText.setFill(tile.getValueColor()); Helper.enableNode(valueText, tile.isValueVisible()); unitText = new Text(tile.getUnit()); unitText.setFill(tile.getUnitColor()); Helper.enableNode(unitText, !tile.getUnit().isEmpty()); valueUnitFlow = new TextFlow(valueText, unitText); valueUnitFlow.setTextAlignment(TextAlignment.RIGHT); description = new Label(tile.getDescription()); description.setAlignment(tile.getDescriptionAlignment()); description.setWrapText(true); description.setTextFill(tile.getTextColor()); Helper.enableNode(description, !tile.getDescription().isEmpty()); triangle = new Path(); triangle.setStroke(null); triangle.setFill(state.color); indicatorPane = new StackPane(triangle); deviationText = new Text(String.format(locale, "%." + tile.getTickLabelDecimals() + "f", deviation)); deviationText.setFill(state.color); deviationUnitText = new Text("%"); deviationUnitText.setFill(Tile.FOREGROUND); referenceUnitFlow = new TextFlow(indicatorPane, deviationText, deviationUnitText); referenceUnitFlow.setTextAlignment(TextAlignment.LEFT); getPane().getChildren().addAll(titleText, text, valueUnitFlow, description, referenceUnitFlow); //handleCurrentValue(tile.getValue()); }
Example 18
Source File: PercentageTileSkin.java From OEE-Designer with MIT License | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); barColor = tile.getBarColor(); barBackground = new Region(); barBackground.setBackground(new Background(new BackgroundFill(tile.getBarBackgroundColor(), new CornerRadii(0.0, 0.0, 0.025, 0.025, true), Insets.EMPTY))); barClip = new Rectangle(); bar = new Rectangle(); bar.setFill(tile.getBarColor()); bar.setStroke(null); bar.setClip(barClip); titleText = new Text(); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); valueText = new Text(String.format(locale, formatString, ((tile.getValue() - minValue) / range * 100))); valueText.setFill(tile.getValueColor()); Helper.enableNode(valueText, tile.isValueVisible()); unitText = new Text(tile.getUnit()); unitText.setFill(tile.getUnitColor()); Helper.enableNode(unitText, !tile.getUnit().isEmpty()); valueUnitFlow = new TextFlow(valueText, unitText); valueUnitFlow.setTextAlignment(TextAlignment.RIGHT); description = new Label(tile.getDescription()); description.setAlignment(tile.getDescriptionAlignment()); description.setWrapText(true); description.setTextFill(tile.getTextColor()); Helper.enableNode(description, !tile.getDescription().isEmpty()); percentageText = new Text(); percentageText.setFill(tile.getBarColor()); percentageUnitText = new Text("%"); percentageUnitText.setFill(tile.getBarColor()); maxValueRect = new Rectangle(); maxValueRect.setFill(tile.getThresholdColor()); maxValueText = new Text(); maxValueText.setFill(tile.getBackgroundColor()); maxValueUnitText = new Text(tile.getUnit()); maxValueUnitText.setFill(tile.getBackgroundColor()); getPane().getChildren().addAll(barBackground, bar, titleText, valueUnitFlow, description, percentageText, percentageUnitText, maxValueRect, maxValueText, maxValueUnitText); }
Example 19
Source File: CountryTileSkin.java From OEE-Designer with MIT License | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); //poiLocations = FXCollections.observableHashMap(); //chartDataLocations = FXCollections.observableHashMap(); //circleHandlerMap = new HashMap<>(); country = tile.getCountry(); if (null == country) { country = Country.DE; } clickHandler = event -> tile.fireTileEvent(new TileEvent(EventType.SELECTED_CHART_DATA, new ChartData(country.getName(), country.getValue(), country.getColor()))); countryPaths = Helper.getHiresCountryPaths().get(country.name()); countryMinX = Helper.MAP_WIDTH; countryMinY = Helper.MAP_HEIGHT; countryMaxX = 0; countryMaxY = 0; countryPaths.forEach(path -> { path.setFill(tile.getBarColor()); countryMinX = Math.min(countryMinX, path.getBoundsInParent().getMinX()); countryMinY = Math.min(countryMinY, path.getBoundsInParent().getMinY()); countryMaxX = Math.max(countryMaxX, path.getBoundsInParent().getMaxX()); countryMaxY = Math.max(countryMaxY, path.getBoundsInParent().getMaxY()); }); /* tile.getPoiList() .forEach(poi -> { String tooltipText = new StringBuilder(poi.getName()).append("\n") .append(poi.getInfo()) .toString(); Circle circle = new Circle(3, poi.getColor()); circle.setOnMousePressed(e -> poi.fireLocationEvent(new LocationEvent(poi))); Tooltip.install(circle, new Tooltip(tooltipText)); poiLocations.put(poi, circle); }); */ titleText = new Text(); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); text = new Text(tile.getCountry().getDisplayName()); text.setFill(tile.getTextColor()); Helper.enableNode(text, tile.isTextVisible()); countryGroup = new Group(); countryGroup.getChildren().setAll(countryPaths); countryContainer = new StackPane(); countryContainer.setMinSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795); countryContainer.setMaxSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795); countryContainer.setPrefSize(size * 0.9, tile.isTextVisible() ? size * 0.72 : size * 0.795); countryContainer.getChildren().setAll(countryGroup); 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); valueUnitFlow.setMouseTransparent(true); getPane().getChildren().addAll(titleText, countryContainer, valueUnitFlow, text); //getPane().getChildren().addAll(poiLocations.values()); }
Example 20
Source File: SparkLineTileSkin.java From OEE-Designer with MIT License | 4 votes |
@Override protected void initGraphics() { super.initGraphics(); averagingListener = o -> handleEvents("AVERAGING"); timeFormatter = DateTimeFormatter.ofPattern("HH:mm", tile.getLocale()); if (tile.isAutoScale()) tile.calcAutoScale(); niceScaleY = new NiceScale(tile.getMinValue(), tile.getMaxValue()); niceScaleY.setMaxTicks(5); tickLineColor = Color.color(tile.getChartGridColor().getRed(), tile.getChartGridColor().getGreen(), tile.getChartGridColor().getBlue(), 0.5); horizontalTickLines = new ArrayList<>(5); tickLabelsY = new ArrayList<>(5); for (int i = 0 ; i < 5 ; i++) { Line hLine = new Line(0, 0, 0, 0); hLine.getStrokeDashArray().addAll(1.0, 2.0); hLine.setStroke(Color.TRANSPARENT); horizontalTickLines.add(hLine); Text tickLabelY = new Text(""); tickLabelY.setFill(Color.TRANSPARENT); tickLabelsY.add(tickLabelY); } gradientLookup = new GradientLookup(tile.getGradientStops()); low = tile.getMaxValue(); high = tile.getMinValue(); stdDeviation = 0; 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.setFill(tile.getValueColor()); Helper.enableNode(valueText, tile.isValueVisible()); unitText = new Text(tile.getUnit()); unitText.setFill(tile.getUnitColor()); Helper.enableNode(unitText, !tile.getUnit().isEmpty()); valueUnitFlow = new TextFlow(valueText, unitText); valueUnitFlow.setTextAlignment(TextAlignment.RIGHT); averageText = new Text(String.format(locale, formatString, tile.getAverage())); averageText.setFill(Tile.FOREGROUND); Helper.enableNode(averageText, tile.isAverageVisible()); 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()); stdDeviationArea = new Rectangle(); Helper.enableNode(stdDeviationArea, tile.isAverageVisible()); averageLine = new Line(); averageLine.setStroke(Tile.FOREGROUND); averageLine.getStrokeDashArray().addAll(PREFERRED_WIDTH * 0.005, PREFERRED_WIDTH * 0.005); Helper.enableNode(averageLine, tile.isAverageVisible()); 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()); getPane().getChildren().addAll(titleText, valueUnitFlow, stdDeviationArea, averageLine, sparkLine, dot, averageText, highText, lowText, timeSpanText, text); getPane().getChildren().addAll(horizontalTickLines); getPane().getChildren().addAll(tickLabelsY); }