Java Code Examples for eu.hansolo.tilesfx.tools.Helper#adjustTextSize()
The following examples show how to use
eu.hansolo.tilesfx.tools.Helper#adjustTextSize() .
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: TurnoverTileSkin.java From tilesfx with Apache License 2.0 | 6 votes |
@Override protected void resizeDynamicText() { double maxWidth = unitText.isVisible() ? width - size * 0.275 : width - size * 0.1; double fontSize = size * 0.24; valueText.setFont(Fonts.latoBold(fontSize)); double correctedFontSize = fontSize; if (valueText.getLayoutBounds().getWidth() > maxWidth) { correctedFontSize = Helper.adjustTextSize(valueText, maxWidth, fontSize); } double fontFactor = correctedFontSize / fontSize; maxWidth = size * 0.275; fontSize = upperUnitText.getText().isEmpty() ? size * 0.12 : size * 0.10; upperUnitText.setFont(Fonts.latoRegular(fontSize * fontFactor)); 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 * fontFactor)); if (unitText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(unitText, maxWidth, fontSize); } }
Example 2
Source File: CircularProgressTileSkin.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 = graphicContainer.isVisible() ? chartSize * 0.15 : chartSize * 0.2; percentageValueText.setFont(Fonts.latoRegular(fontSize)); if (percentageValueText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(percentageValueText, maxWidth, fontSize); } fontSize = graphicContainer.isVisible() ? chartSize * 0.07 : 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 = graphicContainer.isVisible() ? chartSize * 0.075 : chartSize * 0.1; valueText.setFont(Fonts.latoRegular(fontSize)); if (valueText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(valueText, maxWidth, fontSize); } fontSize = graphicContainer.isVisible() ? chartSize * 0.035 : chartSize * 0.04; unitText.setFont(Fonts.latoLight(fontSize)); if (unitText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(unitText, maxWidth, fontSize); } }
Example 3
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 4
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 5
Source File: CircularProgressTileSkin.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 6
Source File: CountdownTimerTileSkin.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 7
Source File: LedTileSkin.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); fontSize = size * 0.1; description.setFont(Fonts.latoRegular(fontSize)); description.setAlignment(Pos.TOP_CENTER); description.setWrapText(false); }
Example 8
Source File: StatusTileSkin.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 9
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 10
Source File: SunburstChartTileSkin.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 11
Source File: SwitchSliderTileSkin.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; } //maxWidth = size * 0.9; 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); maxWidth = width - size * 0.275; fontSize = size * 0.12; unitText.setText(tile.getUnit()); unitText.setFont(Fonts.latoRegular(fontSize)); if (unitText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(unitText, maxWidth, fontSize); } fontSize = size * 0.1; description.setFont(Fonts.latoRegular(fontSize)); }
Example 12
Source File: CalendarTileSkin.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 13
Source File: FireSmokeTileSkin.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 14
Source File: BarGaugeTileSkin.java From tilesfx with Apache License 2.0 | 4 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; } 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); } maxWidth = size * 0.15; fontSize = size * 0.07; minValueText.setFont(Fonts.latoRegular(fontSize)); minValueText.setText(String.format(locale, tickLabelFormatString, minValue)); if (minValueText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(minValueText, maxWidth, fontSize); } minValueText.setX(width * 0.5 - size * 0.2); minValueText.setY(height * 0.85); maxValueText.setFont(Fonts.latoRegular(fontSize)); maxValueText.setText(String.format(locale, tickLabelFormatString, maxValue)); if (maxValueText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(maxValueText, maxWidth, fontSize); } maxValueText.setX(width * 0.5 + size * 0.2 - maxValueText.getLayoutBounds().getWidth()); maxValueText.setY(height * 0.85); maxWidth = width - size * 0.25; fontSize = size * 0.06; 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.1); }
Example 15
Source File: TimerControlTileSkin.java From tilesfx with Apache License 2.0 | 4 votes |
@Override protected void resizeDynamicText() { 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); titleText.setText(tile.getTitle()); 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; } titleText.setY(size * 0.05); maxWidth = width - size * 0.8; amPmText.setFont(font); amPmText.setText(tile.getTime().get(ChronoField.AMPM_OF_DAY) == 0 ? "AM" : "PM"); Helper.adjustTextSize(amPmText, maxWidth, fontSize); amPmText.setX((width - amPmText.getLayoutBounds().getWidth()) * 0.5); amPmText.setY(height * 0.5 - size * 0.1); maxWidth = width - size * 0.4; dateText.setFont(font); if (dateText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(dateText, maxWidth, fontSize); } dateText.setX((width - dateText.getLayoutBounds().getWidth()) * 0.5); dateText.setY(height * 0.5 + size * 0.15); maxWidth = width - size * 0.1; 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 16
Source File: NumberTileSkin.java From tilesfx with Apache License 2.0 | 4 votes |
@Override protected void resizeDynamicText() { double maxWidth = unitText.isVisible() ? 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); } }
Example 17
Source File: TimerControlTileSkin.java From tilesfx with Apache License 2.0 | 4 votes |
public void updateTime(final ZonedDateTime TIME) { if (tile.isDiscreteHours()) { hourRotate.setAngle(TIME.getHour() * 30); } else { hourRotate.setAngle(0.5 * (60 * TIME.getHour() + TIME.getMinute())); } if (tile.isDiscreteMinutes()) { minuteRotate.setAngle(TIME.getMinute() * 6); } else { minuteRotate.setAngle(TIME.getMinute() * 6 + TIME.getSecond() * 0.1); } if (second.isVisible()) { if (tile.isDiscreteSeconds()) { secondRotate.setAngle(TIME.getSecond() * 6); } else { secondRotate.setAngle(TIME.getSecond() * 6 + TIME.get(ChronoField.MILLI_OF_SECOND) * 0.006); } } if (sectionsVisible) { for (TimeSection section : sectionMap.keySet()) { if (highlightSections) { sectionMap.get(section).setStroke(section.contains(TIME.toLocalTime()) ? section.getHighlightColor() : section.getColor()); } else { sectionMap.get(section).setStroke(section.getColor()); } } drawTimeSections(); } amPmText.setText(TIME.get(ChronoField.AMPM_OF_DAY) == 0 ? "AM" : "PM"); Helper.adjustTextSize(amPmText, 0.2 * size, size * 0.05); amPmText.setX((width - amPmText.getLayoutBounds().getWidth()) * 0.5); amPmText.setY(height * 0.5 - size * 0.1); dateText.setText(dateFormatter.format(TIME).toUpperCase()); Helper.adjustTextSize(dateText, 0.3 * size, size * 0.05); dateText.setX((width - dateText.getLayoutBounds().getWidth()) * 0.5); dateText.setY(height * 0.5 + size * 0.15); }
Example 18
Source File: SliderTileSkin.java From tilesfx with Apache License 2.0 | 4 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; } //maxWidth = size * 0.9; 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); 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); } fontSize = size * 0.1; description.setFont(Fonts.latoRegular(fontSize)); }
Example 19
Source File: GaugeTileSkin.java From tilesfx with Apache License 2.0 | 4 votes |
@Override protected void resizeStaticText() { double maxWidth = width - size * 0.1; double fontSize = size * textSize.factor; double textRadius; double sinValue; double cosValue; double textX; double textY; 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; } maxWidth = size * 0.15; fontSize = size * 0.07; maxValueText.setFont(Fonts.latoRegular(fontSize)); if (maxValueText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(maxValueText, maxWidth, fontSize); } textRadius = size * 0.3; sinValue = Math.sin(Math.toRadians(90 + (180 - angleRange) * 0.5)); cosValue = Math.cos(Math.toRadians(90 + (180 - angleRange) * 0.5)); textX = width * 0.5 + textRadius * sinValue; textY = barBackground.getLayoutBounds().getMaxY() + size * 0.05 + textRadius * cosValue; maxValueText.setTranslateX(-maxValueText.getLayoutBounds().getWidth() * 0.5); maxValueText.setTranslateY(-maxValueText.getLayoutBounds().getHeight() * 0.5); maxValueText.relocate(textX, textY); minValueText.setFont(Fonts.latoRegular(maxValueText.getFont().getSize())); if (minValueText.getLayoutBounds().getWidth() > maxWidth) { Helper.adjustTextSize(minValueText, maxWidth, fontSize); } sinValue = Math.sin(Math.toRadians(-90 - (180 - angleRange) * 0.5)); cosValue = Math.cos(Math.toRadians(-90 - (180 - angleRange) * 0.5)); textX = width * 0.5 + textRadius * sinValue; //textY = barBackground.getLayoutBounds().getMaxY() + size * 0.05 + textRadius * cosValue; minValueText.setTranslateX(-minValueText.getLayoutBounds().getWidth() * 0.5); minValueText.setTranslateY(-minValueText.getLayoutBounds().getHeight() * 0.5); minValueText.relocate(textX, textY); if (!sectionsVisible) { maxWidth = size * 0.3; 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); } 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 20
Source File: ImageCounterTileSkin.java From tilesfx with Apache License 2.0 | 4 votes |
@Override protected void resizeDynamicText() { double maxWidth = unitText.isVisible() ? 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); } }