eu.hansolo.tilesfx.tools.Helper Java Examples
The following examples show how to use
eu.hansolo.tilesfx.tools.Helper.
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: RadialPercentageTileSkin.java From tilesfx with Apache License 2.0 | 6 votes |
@Override protected void resizeDynamicText() { double maxWidth = percentageUnitText.isVisible() ? chartSize * 0.7 : chartSize * 0.8; double fontSize = chartSize * 0.2; percentageValueText.setFont(Fonts.latoRegular(fontSize)); if (percentageValueText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(percentageValueText, maxWidth, fontSize); } fontSize = chartSize * 0.08; percentageUnitText.setFont(Fonts.latoLight(fontSize)); if (percentageUnitText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(percentageUnitText, maxWidth, fontSize); } maxWidth = unitText.isVisible() ? chartSize * 0.3 : chartSize * 0.4; fontSize = chartSize * 0.075; descriptionText.setFont(Fonts.latoRegular(fontSize)); if (descriptionText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(descriptionText, maxWidth, fontSize); } fontSize = chartSize * 0.04; unitText.setFont(Fonts.latoLight(fontSize)); if (unitText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(unitText, maxWidth, fontSize); } }
Example #2
Source File: CycleStepTileSkin.java From tilesfx with Apache License 2.0 | 6 votes |
@Override protected void initGraphics() { super.initGraphics(); chartItems = new ArrayList<>(); double sum = tile.getChartData().stream().mapToDouble(chartData -> chartData.getValue()).sum(); tile.getChartData().forEach(chartData -> chartItems.add(new ChartItem(chartData, sum))); chartBox = new VBox(0); chartBox.setFillWidth(true); chartBox.getChildren().addAll(chartItems); 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()); getPane().getChildren().addAll(titleText, text, chartBox); }
Example #3
Source File: SmoothAreaChartTileSkin.java From tilesfx with Apache License 2.0 | 6 votes |
@Override protected void handleEvents(final String EVENT_TYPE) { super.handleEvents(EVENT_TYPE); if (EventType.VISIBILITY.name().equals(EVENT_TYPE)) { Helper.enableNode(titleText, !tile.getTitle().isEmpty()); Helper.enableNode(valueText, tile.isValueVisible()); Helper.enableNode(unitFlow, !tile.getUnit().isEmpty()); Helper.enableNode(dataPointGroup, tile.getDataPointsVisible()); } else if (EventType.SERIES.name().equals(EVENT_TYPE)) { Helper.enableNode(fillPath, ChartType.AREA == tile.getChartType()); } else if (EventType.CLEAR_DATA.name().equals(EVENT_TYPE)) { Platform.runLater(() -> { tile.clearChartData(); fillPath.setVisible(false); strokePath.setVisible(false); Helper.enableNode(dataPointGroup, false); if (tile.getCustomDecimalFormatEnabled()) { valueText.setText(decimalFormat.format(minValue)); } else { valueText.setText(String.format(locale, formatString, minValue)); } }); handleData(); } }
Example #4
Source File: CharacterTileSkin.java From tilesfx with Apache License 2.0 | 6 votes |
@Override protected void initGraphics() { super.initGraphics(); titleText = new Text(); titleText.setFill(tile.getTitleColor()); Helper.enableNode(titleText, !tile.getTitle().isEmpty()); description = new Label(tile.getDescription()); description.setAlignment(Pos.CENTER); description.setTextAlignment(TextAlignment.CENTER); description.setWrapText(true); description.setTextOverrun(OverrunStyle.WORD_ELLIPSIS); description.setTextFill(tile.getTextColor()); description.setPrefSize(PREFERRED_WIDTH * 0.9, PREFERRED_HEIGHT * 0.795); Helper.enableNode(description, tile.isTextVisible()); text = new Text(tile.getText()); text.setFill(tile.getUnitColor()); Helper.enableNode(text, tile.isTextVisible()); getPane().getChildren().addAll(titleText, text, description); }
Example #5
Source File: ColorTileSkin.java From tilesfx with Apache License 2.0 | 6 votes |
@Override protected void resizeStaticText() { double maxWidth = width - size * 0.1; double fontSize = size * textSize.factor; boolean customFontEnabled = tile.isCustomFontEnabled(); Font customFont = tile.getCustomFont(); Font font = (customFontEnabled && customFont != null) ? Font.font(customFont.getFamily(), fontSize) : Fonts.latoRegular(fontSize); titleText.setFont(font); if (titleText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(titleText, maxWidth, fontSize); } switch(tile.getTitleAlignment()) { default : case LEFT : titleText.relocate(size * 0.05, size * 0.05); break; case CENTER: titleText.relocate((width - titleText.getLayoutBounds().getWidth()) * 0.5, size * 0.05); break; case RIGHT : titleText.relocate(width - (size * 0.05) - titleText.getLayoutBounds().getWidth(), size * 0.05); break; } }
Example #6
Source File: CycleStepTileSkin.java From tilesfx with Apache License 2.0 | 6 votes |
private void redraw() { double value = chartData.getValue(); String formatString = "%." + tile.getDecimals() + "f"; double maxTextWidth = width * 0.4; double barStartX = maxTextWidth + 5; double barStartY = height * 0.2; double maxBarWidth = width - barStartX; double barWidth = value / sum * maxBarWidth; double barHeight = height * 0.6; ctx.setTextBaseline(VPos.CENTER); ctx.setFont(Fonts.latoRegular(height * 0.4)); ctx.setTextAlign(TextAlignment.LEFT); ctx.clearRect(0, 0, width, height); ctx.setFill(tile.getForegroundColor()); ctx.fillText(chartData.getName(), 0, height / 2, maxTextWidth); ctx.setFill(Helper.getColorWithOpacity(tile.getForegroundColor(), 0.1)); ctx.fillRect(barStartX, barStartY, maxBarWidth, barHeight); ctx.setFill(chartData.getFillColor()); ctx.fillRect(barStartX + factorX * maxBarWidth, barStartY, barWidth, barHeight); ctx.setFill(tile.getForegroundColor()); ctx.setFont(Fonts.latoRegular(height * 0.3)); ctx.setTextAlign(TextAlignment.CENTER); ctx.fillText(String.format(tile.getLocale(), formatString, value), barStartX + factorX * maxBarWidth + barWidth * 0.5, height * 0.5, maxTextWidth); }
Example #7
Source File: MatrixTileSkin.java From tilesfx with Apache License 2.0 | 6 votes |
private void updateMatrixWithChartData() { List<ChartData> dataList = tile.getChartData(); int cols = dataList.size(); int rows = matrix.getRows(); double factor = rows / tile.getRange(); Color offColor = matrix.getPixelOffColor(); matrix.setAllPixelsOff(); for (int y = rows ; y >= 0 ; y--) { for (int x = 0 ; x < cols; x++) { int noOfActivePixels = Helper.roundDoubleToInt((maxValue - dataList.get(x).getValue()) * factor); matrix.setPixel(x, y, noOfActivePixels <= y ? dataList.get(x).getFillColor() : offColor); } } matrix.drawMatrix(); }
Example #8
Source File: BarChartTileSkin.java From tilesfx with Apache License 2.0 | 6 votes |
private void updateChart() { Platform.runLater(() -> { List<BarChartItem> items = tile.getBarChartItems(); int noOfItems = items.size(); if (noOfItems == 0) { return; } double maxValue = tile.getMaxValue(); double maxY = barChartPane.getLayoutBounds().getMaxY(); double itemHeight = items.get(0).getPrefHeight(); double factorY = Helper.clamp(itemHeight, itemHeight * 1.1, 0.13 * size); for (int i = 0 ; i < noOfItems ; i++) { BarChartItem item = items.get(i); double y = i * factorY; if ((y + itemHeight) < maxY) { item.setMaxValue(maxValue); Helper.enableNode(item, true); item.relocate(0, y); } else { Helper.enableNode(item, false); } } long noOfVisibleItems = items.stream().filter(item -> item.isVisible()).count(); tile.showLowerRightRegion(noOfVisibleItems != noOfItems); }); }
Example #9
Source File: Gauge2TileSkin.java From tilesfx with Apache License 2.0 | 6 votes |
@Override protected void handleCurrentValue(final double VALUE) { double needleStartAngle = angleRange * 0.5; double targetAngle = (VALUE - minValue) * angleStep - needleStartAngle; targetAngle = Helper.clamp(-needleStartAngle, -needleStartAngle + angleRange, targetAngle); needleRotate.setAngle(targetAngle); needleRectRotate.setAngle(targetAngle); bar.setLength(-angleStep * VALUE); if (tile.isStrokeWithGradient()) { needle.setFill(gradientLookup.getColorAt(VALUE / tile.getRange())); bar.setStroke(conicalGradient.getImagePattern(barBounds)); } else { needle.setFill(tile.getNeedleColor()); bar.setStroke(tile.getBarColor()); } if (tile.getCustomDecimalFormatEnabled()) { valueText.setText(decimalFormat.format(VALUE)); } else { valueText.setText(String.format(locale, formatString, VALUE)); } resizeDynamicText(); }
Example #10
Source File: MapTileSkin.java From tilesfx with Apache License 2.0 | 6 votes |
@Override protected void handleEvents(final String EVENT_TYPE) { super.handleEvents(EVENT_TYPE); if ("VISIBILITY".equals(EVENT_TYPE)) { Helper.enableNode(titleText, !tile.getTitle().isEmpty()); Helper.enableNode(text, tile.isTextVisible()); webView.setMaxSize(size * 0.9, tile.isTextVisible() ? size * 0.68 : size * 0.795); webView.setPrefSize(size * 0.9, tile.isTextVisible() ? size * 0.68 : size * 0.795); } else if ("LOCATION".equals(EVENT_TYPE)) { tile.getCurrentLocation().addLocationEventListener(locationListener); updateLocation(); } else if ("TRACK".equals(EVENT_TYPE)) { addTrack(tile.getTrack()); } else if ("MAP_PROVIDER".equals(EVENT_TYPE)) { changeMapProvider(tile.getMapProvider()); } }
Example #11
Source File: TimerControlTileSkin.java From tilesfx with Apache License 2.0 | 6 votes |
@Override protected void handleEvents(final String EVENT_TYPE) { super.handleEvents(EVENT_TYPE); if ("VISIBILITY".equals(EVENT_TYPE)) { Helper.enableNode(titleText, !tile.getTitle().isEmpty()); Helper.enableNode(text, tile.isTextVisible()); Helper.enableNode(dateText, tile.isDateVisible()); Helper.enableNode(second, tile.isSecondsVisible()); Helper.enableNode(sectionsPane, tile.getSectionsVisible()); } else if ("SECTION".equals(EVENT_TYPE)) { sectionMap.clear(); for (TimeSection section : tile.getTimeSections()) { sectionMap.put(section, new Arc()); } sectionsPane.getChildren().setAll(sectionMap.values()); resize(); redraw(); } }
Example #12
Source File: BarGaugeTileSkin.java From tilesfx with Apache License 2.0 | 6 votes |
@Override protected void handleEvents(final String EVENT_TYPE) { super.handleEvents(EVENT_TYPE); if ("VISIBILITY".equals(EVENT_TYPE)) { Helper.enableNode(titleText, !tile.getTitle().isEmpty()); Helper.enableNode(text, tile.isTextVisible()); Helper.enableNode(valueText, tile.isValueVisible()); Helper.enableNode(unitFlow, !tile.getUnit().isEmpty()); Helper.enableNode(lowerThreshold, tile.isLowerThresholdVisible()); Helper.enableNode(lowerThresholdText, tile.isLowerThresholdVisible()); Helper.enableNode(threshold, tile.isThresholdVisible()); Helper.enableNode(thresholdText, tile.isThresholdVisible()); sectionsVisible = tile.getSectionsVisible(); redraw(); } }
Example #13
Source File: GaugeTileSkin.java From tilesfx with Apache License 2.0 | 6 votes |
@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); } 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 #14
Source File: GaugeTileSkin.java From tilesfx with Apache License 2.0 | 6 votes |
@Override protected void handleEvents(final String EVENT_TYPE) { super.handleEvents(EVENT_TYPE); if ("VISIBILITY".equals(EVENT_TYPE)) { Helper.enableNode(titleText, !tile.getTitle().isEmpty()); Helper.enableNode(valueText, tile.isValueVisible()); Helper.enableNode(sectionPane, tile.getSectionsVisible()); Helper.enableNode(thresholdRect, tile.isThresholdVisible()); Helper.enableNode(thresholdText, tile.isThresholdVisible()); Helper.enableNode(unitFlow, !tile.getUnit().isEmpty()); sectionsVisible = tile.getSectionsVisible(); } else if ("SECTION".equals(EVENT_TYPE)) { sections = tile.getSections(); sectionMap.clear(); for(Section section : sections) { sectionMap.put(section, new Arc()); } } else if ("ALERT".equals(EVENT_TYPE)) { Helper.enableNode(valueText, tile.isValueVisible() && !tile.isAlert()); Helper.enableNode(unitText, tile.isValueVisible() && !tile.isAlert()); Helper.enableNode(alertIcon, tile.isAlert()); alertTooltip.setText(tile.getAlertMessage()); } }
Example #15
Source File: GaugeSparkLineTileSkin.java From tilesfx with Apache License 2.0 | 6 votes |
private void smooth(final List<Double> DATA_LIST) { Task<Point[]> smoothTask = new Task<Point[]>() { @Override protected Point[] call() { return Helper.smoothSparkLine(DATA_LIST, minValue, maxValue, graphBounds, noOfDatapoints); } }; smoothTask.setOnSucceeded(t -> { Point[] smoothedPoints = smoothTask.getValue(); int lengthMinusOne = smoothedPoints.length - 1; sparkLine.getElements().clear(); sparkLine.getElements().add(new MoveTo(smoothedPoints[0].getX(), smoothedPoints[0].getY())); for (int i = 1 ; i < lengthMinusOne ; i++) { sparkLine.getElements().add(new LineTo(smoothedPoints[i].getX(), smoothedPoints[i].getY())); } dot.setCenterX(smoothedPoints[lengthMinusOne].getX()); dot.setCenterY(smoothedPoints[lengthMinusOne].getY()); }); Thread smoothThread = new Thread(smoothTask); smoothThread.setDaemon(true); smoothThread.start(); }
Example #16
Source File: SliderTileSkin.java From tilesfx with Apache License 2.0 | 5 votes |
@Override protected void handleEvents(final String EVENT_TYPE) { super.handleEvents(EVENT_TYPE); if ("VISIBILITY".equals(EVENT_TYPE)) { Helper.enableNode(titleText, !tile.getTitle().isEmpty()); Helper.enableNode(text, tile.isTextVisible()); Helper.enableNode(valueText, tile.isValueVisible()); Helper.enableNode(unitFlow, !tile.getUnit().isEmpty()); Helper.enableNode(description, !tile.getDescription().isEmpty()); } }
Example #17
Source File: CustomTileSkin.java From tilesfx with Apache License 2.0 | 5 votes |
@Override protected void resizeStaticText() { double maxWidth = width - size * 0.1; double fontSize = size * textSize.factor; boolean customFontEnabled = tile.isCustomFontEnabled(); Font customFont = tile.getCustomFont(); Font font = (customFontEnabled && customFont != null) ? Font.font(customFont.getFamily(), fontSize) : Fonts.latoRegular(fontSize); titleText.setFont(font); if (titleText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(titleText, maxWidth, fontSize); } switch(tile.getTitleAlignment()) { default : case LEFT : titleText.relocate(size * 0.05, size * 0.05); break; case CENTER: titleText.relocate((width - titleText.getLayoutBounds().getWidth()) * 0.5, size * 0.05); break; case RIGHT : titleText.relocate(width - (size * 0.05) - titleText.getLayoutBounds().getWidth(), size * 0.05); break; } text.setFont(font); if (text.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(text, maxWidth, fontSize); } switch(tile.getTextAlignment()) { default : case LEFT : text.setX(size * 0.05); break; case CENTER: text.setX((width - text.getLayoutBounds().getWidth()) * 0.5); break; case RIGHT : text.setX(width - (size * 0.05) - text.getLayoutBounds().getWidth()); break; } text.setY(height - size * 0.05); }
Example #18
Source File: MatrixTileSkin.java From tilesfx with Apache License 2.0 | 5 votes |
@Override protected void resizeStaticText() { double maxWidth = width - size * 0.1; double fontSize = size * textSize.factor; boolean customFontEnabled = tile.isCustomFontEnabled(); Font customFont = tile.getCustomFont(); Font font = (customFontEnabled && customFont != null) ? Font.font(customFont.getFamily(), fontSize) : Fonts.latoRegular(fontSize); titleText.setFont(font); if (titleText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(titleText, maxWidth, fontSize); } switch(tile.getTitleAlignment()) { default : case LEFT : titleText.relocate(size * 0.05, size * 0.05); break; case CENTER: titleText.relocate((width - titleText.getLayoutBounds().getWidth()) * 0.5, size * 0.05); break; case RIGHT : titleText.relocate(width - (size * 0.05) - titleText.getLayoutBounds().getWidth(), size * 0.05); break; } text.setFont(font); if (text.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(text, maxWidth, fontSize); } switch(tile.getTextAlignment()) { default : case LEFT : text.setX(size * 0.05); break; case CENTER: text.setX((width - text.getLayoutBounds().getWidth()) * 0.5); break; case RIGHT : text.setX(width - (size * 0.05) - text.getLayoutBounds().getWidth()); break; } text.setY(height - size * 0.05); }
Example #19
Source File: SmoothedChart.java From tilesfx with Apache License 2.0 | 5 votes |
private void smooth(ObservableList<PathElement> strokeElements, ObservableList<PathElement> fillElements, final double HEIGHT) { if (fillElements.isEmpty()) return; // as we do not have direct access to the data, first recreate the list of all the data points we have final Point[] dataPoints = new Point[strokeElements.size()]; for (int i = 0; i < strokeElements.size(); i++) { final PathElement element = strokeElements.get(i); if (element instanceof MoveTo) { final MoveTo move = (MoveTo) element; dataPoints[i] = new Point(move.getX(), move.getY()); } else if (element instanceof LineTo) { final LineTo line = (LineTo) element; final double x = line.getX(), y = line.getY(); dataPoints[i] = new Point(x, y); } } double firstX = dataPoints[0].getX(); double lastX = dataPoints[dataPoints.length - 1].getX(); Point[] points = Helper.subdividePoints(dataPoints, getSubDivisions()); fillElements.clear(); fillElements.add(new MoveTo(firstX, HEIGHT)); strokeElements.clear(); strokeElements.add(new MoveTo(points[0].getX(), points[0].getY())); for (Point p : points) { if (Double.compare(p.getX(), firstX) >= 0) { fillElements.add(new LineTo(p.getX(), p.getY())); strokeElements.add(new LineTo(p.getX(), p.getY())); } } fillElements.add(new LineTo(lastX, HEIGHT)); fillElements.add(new LineTo(0, HEIGHT)); fillElements.add(new ClosePath()); }
Example #20
Source File: RadarChartTileSkin.java From tilesfx with Apache License 2.0 | 5 votes |
@Override protected void resizeStaticText() { double maxWidth = width - size * 0.1; double fontSize = size * textSize.factor; boolean customFontEnabled = tile.isCustomFontEnabled(); Font customFont = tile.getCustomFont(); Font font = (customFontEnabled && customFont != null) ? Font.font(customFont.getFamily(), fontSize) : Fonts.latoRegular(fontSize); titleText.setFont(font); if (titleText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(titleText, maxWidth, fontSize); } switch(tile.getTitleAlignment()) { default : case LEFT : titleText.relocate(size * 0.05, size * 0.05); break; case CENTER: titleText.relocate((width - titleText.getLayoutBounds().getWidth()) * 0.5, size * 0.05); break; case RIGHT : titleText.relocate(width - (size * 0.05) - titleText.getLayoutBounds().getWidth(), size * 0.05); break; } text.setFont(font); if (text.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(text, maxWidth, fontSize); } switch(tile.getTextAlignment()) { default : case LEFT : text.setX(size * 0.05); break; case CENTER: text.setX((width - text.getLayoutBounds().getWidth()) * 0.5); break; case RIGHT : text.setX(width - (size * 0.05) - text.getLayoutBounds().getWidth()); break; } text.setY(height - size * 0.05); }
Example #21
Source File: LeaderBoardTileSkin.java From tilesfx with Apache License 2.0 | 5 votes |
@Override protected void resizeStaticText() { double maxWidth = width - size * 0.1; double fontSize = size * textSize.factor; boolean customFontEnabled = tile.isCustomFontEnabled(); Font customFont = tile.getCustomFont(); Font font = (customFontEnabled && customFont != null) ? Font.font(customFont.getFamily(), fontSize) : Fonts.latoRegular(fontSize); titleText.setFont(font); if (titleText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(titleText, maxWidth, fontSize); } switch(tile.getTitleAlignment()) { default : case LEFT : titleText.relocate(size * 0.05, size * 0.05); break; case CENTER: titleText.relocate((width - titleText.getLayoutBounds().getWidth()) * 0.5, size * 0.05); break; case RIGHT : titleText.relocate(width - (size * 0.05) - titleText.getLayoutBounds().getWidth(), size * 0.05); break; } text.setText(tile.getText()); text.setFont(font); if (text.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(text, maxWidth, fontSize); } switch(tile.getTextAlignment()) { default : case LEFT : text.setX(size * 0.05); break; case CENTER: text.setX((width - text.getLayoutBounds().getWidth()) * 0.5); break; case RIGHT : text.setX(width - (size * 0.05) - text.getLayoutBounds().getWidth()); break; } text.setY(height - size * 0.05); }
Example #22
Source File: PercentageTileSkin.java From tilesfx with Apache License 2.0 | 5 votes |
@Override protected void resizeDynamicText() { double maxWidth = unitText.isVisible() ? size * 0.725 : size * 0.9; double fontSize = size * 0.24; valueText.setFont(Fonts.latoRegular(fontSize)); if (valueText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(valueText, maxWidth, fontSize); } percentageUnitText.relocate(percentageText.getLayoutBounds().getMaxX() + size * 0.075, height - size * 0.25); }
Example #23
Source File: RadialPercentageTileSkin.java From tilesfx with Apache License 2.0 | 5 votes |
@Override protected void resizeStaticText() { double maxWidth = width - size * 0.1; double fontSize = size * textSize.factor; boolean customFontEnabled = tile.isCustomFontEnabled(); Font customFont = tile.getCustomFont(); Font font = (customFontEnabled && customFont != null) ? Font.font(customFont.getFamily(), fontSize) : Fonts.latoRegular(fontSize); titleText.setFont(font); if (titleText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(titleText, maxWidth, fontSize); } switch(tile.getTitleAlignment()) { default : case LEFT : titleText.relocate(size * 0.05, size * 0.05); break; case CENTER: titleText.relocate((width - titleText.getLayoutBounds().getWidth()) * 0.5, size * 0.05); break; case RIGHT : titleText.relocate(width - (size * 0.05) - titleText.getLayoutBounds().getWidth(), size * 0.05); break; } text.setFont(font); if (text.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(text, maxWidth, fontSize); } switch(tile.getTextAlignment()) { default : case LEFT : text.setX(size * 0.05); break; case CENTER: text.setX((width - text.getLayoutBounds().getWidth()) * 0.5); break; case RIGHT : text.setX(width - (size * 0.05) - text.getLayoutBounds().getWidth()); break; } text.setY(height - size * 0.05); }
Example #24
Source File: ColorTileSkin.java From tilesfx with Apache License 2.0 | 5 votes |
@Override protected void redraw() { super.redraw(); titleText.setText(tile.getTitle()); if (tile.getCustomDecimalFormatEnabled()) { valueText.setText(decimalFormat.format(Helper.clamp(minValue, maxValue, tile.getCurrentValue()))); } else { valueText.setText(String.format(locale, formatString, Helper.clamp(minValue, maxValue, tile.getCurrentValue()))); } if (tile.getUnit().contains("/")) { String[] units = tile.getUnit().split("/"); upperUnitText.setText(units[0]); unitText.setText(units[1]); Helper.enableNode(fractionLine, true); } else { upperUnitText.setText(" "); unitText.setText(tile.getUnit()); Helper.enableNode(fractionLine, false); } resizeDynamicText(); resizeStaticText(); titleText.setFill(tile.getTitleColor()); valueText.setFill(tile.getValueColor()); upperUnitText.setFill(tile.getUnitColor()); fractionLine.setStroke(tile.getUnitColor()); unitText.setFill(tile.getUnitColor()); if (tile.isFillWithGradient() && !tile.getGradientStops().isEmpty()) { gradientLookup.setStops(tile.getGradientStops()); } barBackground.setFill(tile.getBarBackgroundColor()); bar.setFill(tile.getForegroundColor()); }
Example #25
Source File: BarChartTileSkin.java From tilesfx with Apache License 2.0 | 5 votes |
@Override protected void handleEvents(final String EVENT_TYPE) { super.handleEvents(EVENT_TYPE); if (EventType.VISIBILITY.name().equals(EVENT_TYPE)) { Helper.enableNode(titleText, !tile.getTitle().isEmpty()); Helper.enableNode(text, tile.isTextVisible()); } else if (EventType.DATA.name().equals(EVENT_TYPE)) { sortItems(); } else if (EventType.ANIMATED_ON.name().equals(EVENT_TYPE)) { tile.getBarChartItems().forEach(item -> item.getChartData().setAnimated(true)); } else if (EventType.ANIMATED_OFF.name().equals(EVENT_TYPE)) { tile.getBarChartItems().forEach(item -> item.getChartData().setAnimated(false)); } }
Example #26
Source File: CountryTileSkin.java From tilesfx with Apache License 2.0 | 5 votes |
@Override protected void resizeStaticText() { double maxWidth = width - size * 0.1; double fontSize = size * textSize.factor; boolean customFontEnabled = tile.isCustomFontEnabled(); Font customFont = tile.getCustomFont(); Font font = (customFontEnabled && customFont != null) ? Font.font(customFont.getFamily(), fontSize) : Fonts.latoRegular(fontSize); titleText.setFont(font); if (titleText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(titleText, maxWidth, fontSize); } switch(tile.getTitleAlignment()) { default : case LEFT : titleText.relocate(size * 0.05, size * 0.05); break; case CENTER: titleText.relocate((width - titleText.getLayoutBounds().getWidth()) * 0.5, size * 0.05); break; case RIGHT : titleText.relocate(width - (size * 0.05) - titleText.getLayoutBounds().getWidth(), size * 0.05); break; } text.setFont(font); if (text.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(text, maxWidth, fontSize); } switch(tile.getTextAlignment()) { default : case LEFT : text.setX(size * 0.05); break; case CENTER: text.setX((width - text.getLayoutBounds().getWidth()) * 0.5); break; case RIGHT : text.setX(width - (size * 0.05) - text.getLayoutBounds().getWidth()); break; } text.setY(height - size * 0.05); maxWidth = width - (width - size * 0.275); fontSize = upperUnitText.getText().isEmpty() ? size * 0.12 : size * 0.10; upperUnitText.setFont(Fonts.latoRegular(fontSize)); if (upperUnitText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(upperUnitText, maxWidth, fontSize); } fontSize = upperUnitText.getText().isEmpty() ? size * 0.12 : size * 0.10; unitText.setFont(Fonts.latoRegular(fontSize)); if (unitText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(unitText, maxWidth, fontSize); } }
Example #27
Source File: ImageCounterTileSkin.java From tilesfx with Apache License 2.0 | 5 votes |
@Override protected void handleEvents(final String EVENT_TYPE) { super.handleEvents(EVENT_TYPE); if ("VISIBILITY".equals(EVENT_TYPE)) { Helper.enableNode(titleText, !tile.getTitle().isEmpty()); Helper.enableNode(text, tile.isTextVisible()); graphicContainer.setMaxSize(size * 0.9, tile.isTextVisible() ? size * 0.68 : size * 0.795); graphicContainer.setPrefSize(size * 0.9, tile.isTextVisible() ? size * 0.68 : size * 0.795); Helper.enableNode(valueText, tile.isValueVisible()); Helper.enableNode(unitFlow, !tile.getUnit().isEmpty()); } }
Example #28
Source File: CountdownTimerTileSkin.java From tilesfx with Apache License 2.0 | 5 votes |
@Override protected void resizeDynamicText() { double maxWidth = chartSize * 0.8; double fontSize = chartSize * 0.15; durationText.setFont(Fonts.latoRegular(fontSize)); if (durationText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(durationText, maxWidth, fontSize); } maxWidth = chartSize * 0.4; fontSize = chartSize * 0.1; timeText.setFont(Fonts.latoRegular(fontSize)); if (timeText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(timeText, maxWidth, fontSize); } }
Example #29
Source File: LeaderBoardTileSkin.java From tilesfx with Apache License 2.0 | 5 votes |
private void resizeItems() { double itemHeight = Helper.clamp(30, 72, height * 0.14); leaderBoardPane.getChildren().forEach(node -> { LeaderBoardItem item = (LeaderBoardItem) node; item.setParentSize(width, height); item.setPrefSize(width, itemHeight); item.setMaxSize(width, itemHeight); }); }
Example #30
Source File: ClockTileSkin.java From tilesfx with Apache License 2.0 | 5 votes |
@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); }