From deb27f576a225fbf8202bc55a7cc14cebf1c5577 Mon Sep 17 00:00:00 2001 From: mkpaz Date: Thu, 9 Feb 2023 20:08:30 +0400 Subject: [PATCH] Checkstyle: reformat code --- .../atlantafx/base/controls/BehaviorBase.java | 5 +- .../base/controls/BehaviorSkinBase.java | 4 +- .../atlantafx/base/controls/Breadcrumbs.java | 37 ++-- .../base/controls/BreadcrumbsSkin.java | 13 +- .../base/controls/CaptionMenuItem.java | 1 + .../base/controls/CustomTextField.java | 9 +- .../base/controls/CustomTextFieldSkin.java | 1 + .../base/controls/InlineDatePicker.java | 39 ++-- .../controls/InlineDatePickerBehavior.java | 5 +- .../base/controls/InlineDatePickerSkin.java | 54 +++--- .../java/atlantafx/base/controls/Popover.java | 78 +++----- .../atlantafx/base/controls/PopoverSkin.java | 166 ++++++++-------- .../base/controls/ProgressSliderSkin.java | 8 +- .../base/controls/RingProgressIndicator.java | 11 +- .../controls/RingProgressIndicatorSkin.java | 32 ++-- .../java/atlantafx/base/controls/Spacer.java | 1 + .../atlantafx/base/controls/ToggleSwitch.java | 25 ++- .../base/controls/ToggleSwitchSkin.java | 30 +-- .../java/atlantafx/base/theme/NordDark.java | 1 + .../java/atlantafx/base/theme/NordLight.java | 1 + .../java/atlantafx/base/theme/PrimerDark.java | 1 + .../atlantafx/base/theme/PrimerLight.java | 1 + .../java/atlantafx/base/theme/Styles.java | 19 +- .../main/java/atlantafx/base/theme/Theme.java | 10 +- .../base/util/DoubleStringConverter.java | 9 +- .../base/util/IntegerStringConverter.java | 9 +- .../base/util/PasswordTextFormatter.java | 14 +- .../atlantafx/base/util/PlatformUtils.java | 1 + .../base/util/PasswordTextFormatterTest.java | 3 +- .../sampler/DefaultExceptionHandler.java | 5 +- .../java/atlantafx/sampler/FileResource.java | 5 +- .../main/java/atlantafx/sampler/Launcher.java | 12 +- .../java/atlantafx/sampler/Resources.java | 5 +- .../atlantafx/sampler/event/BrowseEvent.java | 5 +- .../sampler/event/DefaultEventBus.java | 16 +- .../java/atlantafx/sampler/event/Event.java | 16 +- .../atlantafx/sampler/event/EventBus.java | 9 +- .../atlantafx/sampler/event/HotkeyEvent.java | 5 +- .../atlantafx/sampler/event/Listener.java | 4 +- .../atlantafx/sampler/event/ThemeEvent.java | 4 +- .../atlantafx/sampler/fake/SampleMenuBar.java | 75 ++++---- .../atlantafx/sampler/fake/domain/Book.java | 55 ++++-- .../sampler/fake/domain/Product.java | 65 +++++-- .../sampler/layout/ApplicationWindow.java | 5 +- .../atlantafx/sampler/layout/HeaderBar.java | 25 +-- .../atlantafx/sampler/layout/MainLayer.java | 24 ++- .../atlantafx/sampler/layout/MainModel.java | 1 + .../atlantafx/sampler/layout/Overlay.java | 24 ++- .../atlantafx/sampler/layout/Sidebar.java | 124 ++++++------ .../atlantafx/sampler/page/AbstractPage.java | 8 +- .../atlantafx/sampler/page/CodeViewer.java | 37 ++-- .../atlantafx/sampler/page/OverlayDialog.java | 13 +- .../java/atlantafx/sampler/page/Page.java | 1 + .../sampler/page/QuickConfigMenu.java | 27 +-- .../atlantafx/sampler/page/SampleBlock.java | 1 + .../page/components/AccordionPage.java | 35 ++-- .../page/components/BreadcrumbsPage.java | 27 ++- .../sampler/page/components/ButtonPage.java | 33 ++-- .../sampler/page/components/ChartPage.java | 99 ++++++---- .../sampler/page/components/CheckBoxPage.java | 29 +-- .../page/components/ColorPickerPage.java | 25 ++- .../sampler/page/components/ComboBoxPage.java | 22 ++- .../page/components/CustomTextFieldPage.java | 19 +- .../page/components/DatePickerPage.java | 115 ++++++----- .../sampler/page/components/DialogPage.java | 29 +-- .../page/components/HTMLEditorPage.java | 31 +-- .../page/components/InputGroupPage.java | 21 +- .../sampler/page/components/LabelPage.java | 25 +-- .../sampler/page/components/ListPage.java | 107 +++++++---- .../page/components/MenuButtonPage.java | 19 +- .../sampler/page/components/MenuPage.java | 27 +-- .../sampler/page/components/OverviewPage.java | 29 +-- .../page/components/PaginationPage.java | 17 +- .../sampler/page/components/PopoverPage.java | 28 +-- .../sampler/page/components/ProgressPage.java | 83 ++++---- .../page/components/RadioButtonPage.java | 13 +- .../page/components/ScrollPanePage.java | 23 ++- .../page/components/SeparatorPage.java | 41 ++-- .../sampler/page/components/SliderPage.java | 15 +- .../sampler/page/components/SpinnerPage.java | 21 +- .../page/components/SplitPanePage.java | 23 ++- .../sampler/page/components/TabPanePage.java | 43 +++-- .../sampler/page/components/TablePage.java | 73 +++---- .../sampler/page/components/TextAreaPage.java | 23 ++- .../page/components/TextFieldPage.java | 15 +- .../page/components/TitledPanePage.java | 41 ++-- .../page/components/ToggleButtonPage.java | 35 ++-- .../page/components/ToggleSwitchPage.java | 9 +- .../sampler/page/components/ToolBarPage.java | 20 +- .../sampler/page/components/TooltipPage.java | 33 ++-- .../sampler/page/components/TreePage.java | 77 +++++--- .../page/components/TreeTablePage.java | 57 +++--- .../page/general/AccentColorSelector.java | 9 +- .../sampler/page/general/ColorPalette.java | 32 ++-- .../page/general/ColorPaletteBlock.java | 19 +- .../sampler/page/general/ColorScale.java | 25 +-- .../sampler/page/general/ColorScaleBlock.java | 7 +- .../sampler/page/general/ContrastChecker.java | 148 +++++++++----- .../page/general/ContrastCheckerDialog.java | 5 +- .../sampler/page/general/IconBrowser.java | 4 +- .../sampler/page/general/IconsPage.java | 65 ++++--- .../sampler/page/general/ThemePage.java | 58 +++--- .../page/general/ThemeRepoManager.java | 20 +- .../page/general/ThemeRepoManagerDialog.java | 5 +- .../sampler/page/general/TypographyPage.java | 159 +++++++-------- .../page/showcase/filemanager/Bookmark.java | 4 +- .../showcase/filemanager/BookmarkList.java | 12 +- .../showcase/filemanager/DirectoryView.java | 1 + .../filemanager/FileIconRepository.java | 15 +- .../page/showcase/filemanager/FileList.java | 7 +- .../showcase/filemanager/FileManagerPage.java | 46 +++-- .../page/showcase/filemanager/Model.java | 13 +- .../filemanager/NavigationHistory.java | 21 +- .../showcase/filemanager/RightClickMenu.java | 19 +- .../filemanager/TableDirectoryView.java | 7 +- .../page/showcase/filemanager/Utils.java | 1 + .../page/showcase/musicplayer/ColorThief.java | 68 ++++--- .../page/showcase/musicplayer/MediaFile.java | 15 +- .../page/showcase/musicplayer/Model.java | 37 +++- .../showcase/musicplayer/MusicPlayerPage.java | 11 +- .../page/showcase/musicplayer/PlayerPane.java | 36 +++- .../showcase/musicplayer/PlayerScreen.java | 25 +-- .../showcase/musicplayer/PlaylistPane.java | 21 +- .../showcase/musicplayer/StartScreen.java | 23 ++- .../page/showcase/musicplayer/Utils.java | 9 +- .../sampler/page/showcase/widget/Card.java | 51 ++--- .../page/showcase/widget/CardSample.java | 39 ++-- .../sampler/page/showcase/widget/Message.java | 75 ++++---- .../page/showcase/widget/MessageSample.java | 1 + .../sampler/page/showcase/widget/Stepper.java | 137 +++++++------ .../page/showcase/widget/StepperSample.java | 17 +- .../sampler/page/showcase/widget/Tag.java | 17 +- .../page/showcase/widget/TagSample.java | 37 ++-- .../showcase/widget/WidgetCollectionPage.java | 16 +- .../atlantafx/sampler/theme/CSSFragment.java | 9 +- .../sampler/theme/HighlightJSTheme.java | 13 +- .../atlantafx/sampler/theme/SamplerTheme.java | 22 ++- .../atlantafx/sampler/theme/ThemeManager.java | 46 +++-- .../sampler/theme/ThemeRepository.java | 27 +-- .../atlantafx/sampler/util/Animations.java | 59 +++--- .../atlantafx/sampler/util/Containers.java | 17 +- .../atlantafx/sampler/util/ContrastLevel.java | 11 +- .../java/atlantafx/sampler/util/Controls.java | 21 +- .../sampler/util/HumanReadableFormat.java | 21 +- .../java/atlantafx/sampler/util/JColor.java | 181 ++++++++---------- .../atlantafx/sampler/util/JColorUtils.java | 97 +++++----- .../atlantafx/sampler/util/NodeUtils.java | 13 +- 147 files changed, 2566 insertions(+), 1849 deletions(-) diff --git a/base/src/main/java/atlantafx/base/controls/BehaviorBase.java b/base/src/main/java/atlantafx/base/controls/BehaviorBase.java index a1be0ff..0ecf723 100755 --- a/base/src/main/java/atlantafx/base/controls/BehaviorBase.java +++ b/base/src/main/java/atlantafx/base/controls/BehaviorBase.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.base.controls; import javafx.scene.control.Control; @@ -22,7 +23,9 @@ public abstract class BehaviorBase> { return skin; } - /** Called from {@link SkinBase#dispose()} to clean up the behavior state */ + /** + * Called from {@link SkinBase#dispose()} to clean up the behavior state + */ public void dispose() { this.control = null; this.skin = null; diff --git a/base/src/main/java/atlantafx/base/controls/BehaviorSkinBase.java b/base/src/main/java/atlantafx/base/controls/BehaviorSkinBase.java index cd75b7e..bc544aa 100755 --- a/base/src/main/java/atlantafx/base/controls/BehaviorSkinBase.java +++ b/base/src/main/java/atlantafx/base/controls/BehaviorSkinBase.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.base.controls; import java.util.function.Consumer; @@ -31,7 +32,8 @@ public abstract class BehaviorSkinBase extends Control { protected static final String DEFAULT_STYLE_CLASS = "breadcrumbs"; protected final Callback, ButtonBase> defaultCrumbNodeFactory = - item -> new Hyperlink(item.getStringValue()); + item -> new Hyperlink(item.getStringValue()); protected final Callback, ? extends Node> defaultDividerFactory = - item -> item != null && !item.isLast() ? new Label("/") : null; + item -> item != null && !item.isLast() ? new Label("/") : null; - /** Creates an empty bread crumb bar. */ + /** + * Creates an empty bread crumb bar. + */ public Breadcrumbs() { this(null); } @@ -88,7 +91,9 @@ public class Breadcrumbs extends Control { setDividerFactory(defaultDividerFactory); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override protected Skin createDefaultSkin() { return new BreadcrumbsSkin<>(this); @@ -131,7 +136,7 @@ public class Breadcrumbs extends Control { } protected final ObjectProperty> selectedCrumb = - new SimpleObjectProperty<>(this, "selectedCrumb"); + new SimpleObjectProperty<>(this, "selectedCrumb"); public final BreadCrumbItem getSelectedCrumb() { return selectedCrumb.get(); @@ -153,7 +158,7 @@ public class Breadcrumbs extends Control { } protected final BooleanProperty autoNavigation = - new SimpleBooleanProperty(this, "autoNavigationEnabled", true); + new SimpleBooleanProperty(this, "autoNavigationEnabled", true); public final boolean isAutoNavigationEnabled() { return autoNavigation.get(); @@ -178,7 +183,7 @@ public class Breadcrumbs extends Control { } protected final ObjectProperty, ButtonBase>> crumbFactory = - new SimpleObjectProperty<>(this, "crumbFactory"); + new SimpleObjectProperty<>(this, "crumbFactory"); public final void setCrumbFactory(Callback, ButtonBase> value) { if (value == null) { @@ -208,7 +213,7 @@ public class Breadcrumbs extends Control { } protected final ObjectProperty, ? extends Node>> dividerFactory = - new SimpleObjectProperty<>(this, "dividerFactory"); + new SimpleObjectProperty<>(this, "dividerFactory"); public final void setDividerFactory(Callback, ? extends Node> value) { if (value == null) { @@ -228,7 +233,9 @@ public class Breadcrumbs extends Control { return onCrumbAction; } - /** Set a new EventHandler for when a user selects a crumb. */ + /** + * Set a new EventHandler for when a user selects a crumb. + */ public final void setOnCrumbAction(EventHandler> value) { onCrumbActionProperty().set(value); } @@ -239,7 +246,7 @@ public class Breadcrumbs extends Control { protected final ObjectProperty>> onCrumbAction = new ObjectPropertyBase<>() { - @SuppressWarnings({ "unchecked", "rawtypes" }) + @SuppressWarnings({"unchecked", "rawtypes"}) @Override protected void invalidated() { setEventHandler(BreadCrumbActionEvent.CRUMB_ACTION, (EventHandler) (Object) get()); @@ -289,7 +296,9 @@ public class Breadcrumbs extends Control { } } - /** Represents an Event which is fired when a bread crumb was activated. */ + /** + * Represents an Event which is fired when a bread crumb was activated. + */ public static class BreadCrumbActionEvent extends Event { /** @@ -298,11 +307,13 @@ public class Breadcrumbs extends Control { * has changed. */ public static final EventType> CRUMB_ACTION - = new EventType<>("CRUMB_ACTION" + UUID.randomUUID()); + = new EventType<>("CRUMB_ACTION" + UUID.randomUUID()); private final BreadCrumbItem selectedCrumb; - /** Creates a new event that can subsequently be fired. */ + /** + * Creates a new event that can subsequently be fired. + */ public BreadCrumbActionEvent(BreadCrumbItem selectedCrumb) { super(CRUMB_ACTION); this.selectedCrumb = selectedCrumb; diff --git a/base/src/main/java/atlantafx/base/controls/BreadcrumbsSkin.java b/base/src/main/java/atlantafx/base/controls/BreadcrumbsSkin.java index bdf3bab..41112e1 100755 --- a/base/src/main/java/atlantafx/base/controls/BreadcrumbsSkin.java +++ b/base/src/main/java/atlantafx/base/controls/BreadcrumbsSkin.java @@ -26,6 +26,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package atlantafx.base.controls; import atlantafx.base.controls.Breadcrumbs.BreadCrumbItem; @@ -78,7 +79,9 @@ public class BreadcrumbsSkin extends SkinBase> { double bottomInset, double leftInset) { double width = 0; for (Node node : getChildren()) { - if (!node.isManaged()) { continue; } + if (!node.isManaged()) { + continue; + } width += snapSizeX(node.prefWidth(height)); } @@ -148,8 +151,12 @@ public class BreadcrumbsSkin extends SkinBase> { Collections.reverse(path); // if the path consists of a single item it considered as first, but not last - if (path.size() > 0) { path.get(0).setFirst(true); } - if (path.size() > 1) { path.get(path.size() - 1).setLast(true); } + if (path.size() > 0) { + path.get(0).setFirst(true); + } + if (path.size() > 1) { + path.get(path.size() - 1).setLast(true); + } return path; } diff --git a/base/src/main/java/atlantafx/base/controls/CaptionMenuItem.java b/base/src/main/java/atlantafx/base/controls/CaptionMenuItem.java index 270aa9d..ea1bc95 100644 --- a/base/src/main/java/atlantafx/base/controls/CaptionMenuItem.java +++ b/base/src/main/java/atlantafx/base/controls/CaptionMenuItem.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.base.controls; import javafx.beans.property.StringProperty; diff --git a/base/src/main/java/atlantafx/base/controls/CustomTextField.java b/base/src/main/java/atlantafx/base/controls/CustomTextField.java index 4bc3dd0..a96dc0c 100755 --- a/base/src/main/java/atlantafx/base/controls/CustomTextField.java +++ b/base/src/main/java/atlantafx/base/controls/CustomTextField.java @@ -26,6 +26,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package atlantafx.base.controls; import javafx.beans.property.ObjectProperty; @@ -41,7 +42,9 @@ import javafx.scene.control.TextField; @SuppressWarnings("unused") public class CustomTextField extends TextField { - /** Instantiates a default CustomTextField. */ + /** + * Instantiates a default CustomTextField. + */ public CustomTextField() { getStyleClass().add("custom-text-field"); } @@ -106,7 +109,9 @@ public class CustomTextField extends TextField { // Methods // /////////////////////////////////////////////////////////////////////////// - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override protected Skin createDefaultSkin() { return new CustomTextFieldSkin(this) { diff --git a/base/src/main/java/atlantafx/base/controls/CustomTextFieldSkin.java b/base/src/main/java/atlantafx/base/controls/CustomTextFieldSkin.java index e961c9f..df8131f 100755 --- a/base/src/main/java/atlantafx/base/controls/CustomTextFieldSkin.java +++ b/base/src/main/java/atlantafx/base/controls/CustomTextFieldSkin.java @@ -26,6 +26,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package atlantafx.base.controls; import javafx.beans.property.ObjectProperty; diff --git a/base/src/main/java/atlantafx/base/controls/InlineDatePicker.java b/base/src/main/java/atlantafx/base/controls/InlineDatePicker.java index a702c9e..f92093a 100755 --- a/base/src/main/java/atlantafx/base/controls/InlineDatePicker.java +++ b/base/src/main/java/atlantafx/base/controls/InlineDatePicker.java @@ -24,6 +24,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + package atlantafx.base.controls; import java.time.DateTimeException; @@ -72,7 +73,9 @@ public class InlineDatePicker extends Control { protected LocalDate lastValidDate = null; protected Chronology lastValidChronology = IsoChronology.INSTANCE; - /** Creates a default DatePicker instance with a null date value set. */ + /** + * Creates a default DatePicker instance with a null date value set. + */ public InlineDatePicker() { this(null); @@ -111,7 +114,9 @@ public class InlineDatePicker extends Control { getStyleClass().add(DEFAULT_STYLE_CLASS); } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override protected Skin createDefaultSkin() { return new InlineDatePickerSkin(this); @@ -131,7 +136,9 @@ public class InlineDatePicker extends Control { valueProperty().set(value); } - public ObjectProperty valueProperty() { return value; } + public ObjectProperty valueProperty() { + return value; + } /** * A custom cell factory can be provided to customize individual day cells @@ -270,18 +277,18 @@ public class InlineDatePicker extends Control { private static final List> STYLEABLES; private static final CssMetaData SHOW_WEEK_NUMBERS = - new CssMetaData<>("-fx-show-week-numbers", BooleanConverter.getInstance(), false) { - @Override - public boolean isSettable(InlineDatePicker n) { - return n.showWeekNumbers == null || !n.showWeekNumbers.isBound(); - } + new CssMetaData<>("-fx-show-week-numbers", BooleanConverter.getInstance(), false) { + @Override + public boolean isSettable(InlineDatePicker n) { + return n.showWeekNumbers == null || !n.showWeekNumbers.isBound(); + } - @Override - @SuppressWarnings("RedundantCast") - public StyleableProperty getStyleableProperty(InlineDatePicker n) { - return (StyleableProperty) (WritableValue) n.showWeekNumbersProperty(); - } - }; + @Override + @SuppressWarnings("RedundantCast") + public StyleableProperty getStyleableProperty(InlineDatePicker n) { + return (StyleableProperty) (WritableValue) n.showWeekNumbersProperty(); + } + }; static { final List> styleables = new ArrayList<>(Control.getClassCssMetaData()); @@ -298,7 +305,9 @@ public class InlineDatePicker extends Control { return StyleableProperties.STYLEABLES; } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override public List> getControlCssMetaData() { return getClassCssMetaData(); diff --git a/base/src/main/java/atlantafx/base/controls/InlineDatePickerBehavior.java b/base/src/main/java/atlantafx/base/controls/InlineDatePickerBehavior.java index 90c8043..5fc2d8c 100755 --- a/base/src/main/java/atlantafx/base/controls/InlineDatePickerBehavior.java +++ b/base/src/main/java/atlantafx/base/controls/InlineDatePickerBehavior.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.base.controls; import static atlantafx.base.util.PlatformUtils.isMac; @@ -56,7 +57,9 @@ public class InlineDatePickerBehavior extends BehaviorBase displayedYearMonth = new SimpleObjectProperty<>(this, "displayedYearMonth"); - public ObjectProperty displayedYearMonthProperty() { return displayedYearMonth; } + public ObjectProperty displayedYearMonthProperty() { + return displayedYearMonth; + } - private final ObjectBinding firstDayOfMonth = Bindings.createObjectBinding(() -> displayedYearMonth.get().atDay(1), displayedYearMonth); + private final ObjectBinding firstDayOfMonth = + Bindings.createObjectBinding(() -> displayedYearMonth.get().atDay(1), displayedYearMonth); - public LocalDate getFirstDayOfMonth() { return firstDayOfMonth.get(); } + public LocalDate getFirstDayOfMonth() { + return firstDayOfMonth.get(); + } public InlineDatePickerSkin(InlineDatePicker datePicker) { super(datePicker); @@ -115,7 +121,7 @@ public class InlineDatePickerSkin extends BehaviorSkinBase { LocalDate date = datePicker.getValue(); displayedYearMonthProperty().set( - date != null ? YearMonth.from(date) : YearMonth.now(ZoneId.systemDefault()) + date != null ? YearMonth.from(date) : YearMonth.now(ZoneId.systemDefault()) ); updateValues(); datePicker.fireEvent(new ActionEvent()); @@ -197,7 +203,7 @@ public class InlineDatePickerSkin extends BehaviorSkinBase updateValues()); @@ -381,9 +387,9 @@ public class InlineDatePickerSkin extends BehaviorSkinBase dayCellActionHandler = e -> { - if (e.getButton() != MouseButton.PRIMARY) { return; } + if (e.getButton() != MouseButton.PRIMARY) { + return; + } DateCell dayCell = (DateCell) e.getSource(); selectDayCell(dayCell); lastFocusedDayCell = dayCell; @@ -570,8 +578,8 @@ public class InlineDatePickerSkin extends BehaviorSkinBase factory = getControl().getDayCellFactory(); return Objects.requireNonNullElseGet( - factory != null ? factory.call(getControl()) : null, - DateCell::new + factory != null ? factory.call(getControl()) : null, + DateCell::new ); } @@ -612,8 +620,8 @@ public class InlineDatePickerSkin extends BehaviorSkinBase closePopoverOnOwnerWindowCloseLambda = event -> ownerWindowHiding(); private final WeakEventHandler closePopoverOnOwnerWindowClose = - new WeakEventHandler<>(closePopoverOnOwnerWindowCloseLambda); + new WeakEventHandler<>(closePopoverOnOwnerWindowCloseLambda); /** * Shows the popover in a position relative to the edges of the given owner @@ -247,10 +246,10 @@ public class Popover extends PopupControl { * given owner. If the arrow points up then the popover will be placed * below the given owner node. * - * @param owner the owner of the popover + * @param owner the owner of the popover * @param offset if negative specifies the distance to the owner node or when - * positive specifies the number of pixels that the arrow will - * overlap with the owner node (positive values are recommended) + * positive specifies the number of pixels that the arrow will + * overlap with the owner node (positive values are recommended) */ public final void show(Node owner, double offset) { requireNonNull(owner); @@ -259,16 +258,16 @@ public class Popover extends PopupControl { switch (getArrowLocation()) { case BOTTOM_CENTER, BOTTOM_LEFT, BOTTOM_RIGHT -> show( - owner, bounds.getMinX() + bounds.getWidth() / 2, bounds.getMinY() + offset + owner, bounds.getMinX() + bounds.getWidth() / 2, bounds.getMinY() + offset ); case LEFT_BOTTOM, LEFT_CENTER, LEFT_TOP -> show( - owner, bounds.getMaxX() - offset, bounds.getMinY() + bounds.getHeight() / 2 + owner, bounds.getMaxX() - offset, bounds.getMinY() + bounds.getHeight() / 2 ); case RIGHT_BOTTOM, RIGHT_CENTER, RIGHT_TOP -> show( - owner, bounds.getMinX() + offset, bounds.getMinY() + bounds.getHeight() / 2 + owner, bounds.getMinX() + offset, bounds.getMinY() + bounds.getHeight() / 2 ); case TOP_CENTER, TOP_LEFT, TOP_RIGHT -> show( - owner, bounds.getMinX() + bounds.getWidth() / 2, bounds.getMinY() + bounds.getHeight() - offset + owner, bounds.getMinX() + bounds.getWidth() / 2, bounds.getMinY() + bounds.getHeight() - offset ); } } @@ -309,8 +308,8 @@ public class Popover extends PopupControl { * of the arrow of the popover and not the location of the window. * * @param owner the owning node - * @param x the x coordinate for the popover arrow tip - * @param y the y coordinate for the popover arrow tip + * @param x the x coordinate for the popover arrow tip + * @param y the y coordinate for the popover arrow tip */ @Override public final void show(Node owner, double x, double y) { @@ -322,11 +321,11 @@ public class Popover extends PopupControl { * the given owner node. The x and y coordinate will be the target location * of the arrow of the popover and not the location of the window. * - * @param owner the owning node - * @param x the x coordinate for the popover arrow tip - * @param y the y coordinate for the popover arrow tip + * @param owner the owning node + * @param x the x coordinate for the popover arrow tip + * @param y the y coordinate for the popover arrow tip * @param fadeInDuration the time it takes for the popover to be fully visible. - * This duration takes precedence over the fade-in property without setting. + * This duration takes precedence over the fade-in property without setting. */ public final void show(Node owner, double x, double y, Duration fadeInDuration) { /* @@ -379,7 +378,8 @@ public class Popover extends PopupControl { // due to JavaFX async nature. The only way seems to start popover as invisible (not opaque) // and then restore its visibility after a fixed delay to hide window repositioning. // Still it's not a 100% guarantee,but better than nothing. - int delay = Math.min((int) Objects.requireNonNullElse(fadeInDuration, DEFAULT_FADE_DURATION).toMillis() / 2, 250); + int delay = + Math.min((int) Objects.requireNonNullElse(fadeInDuration, DEFAULT_FADE_DURATION).toMillis() / 2, 250); new Timer().schedule(new TimerTask() { @Override public void run() { @@ -430,7 +430,7 @@ public class Popover extends PopupControl { * Hides the popover by quickly changing its opacity to 0. * * @param fadeOutDuration the duration of the fade transition that is being used to - * change the opacity of the popover + * change the opacity of the popover */ public final void hide(Duration fadeOutDuration) { if (fadeOutDuration == null) { @@ -479,13 +479,13 @@ public class Popover extends PopupControl { private double computeXOffset() { return switch (getArrowLocation()) { case TOP_LEFT, BOTTOM_LEFT -> ( - getCornerRadius() + getArrowIndent() + getArrowSize() + getCornerRadius() + getArrowIndent() + getArrowSize() ); case TOP_CENTER, BOTTOM_CENTER -> ( - getContentNode().prefWidth(-1) / 2 + getContentNode().prefWidth(-1) / 2 ); case TOP_RIGHT, BOTTOM_RIGHT -> ( - getContentNode().prefWidth(-1) - getArrowIndent() - getCornerRadius() - getArrowSize() + getContentNode().prefWidth(-1) - getArrowIndent() - getCornerRadius() - getArrowSize() ); default -> 0; }; @@ -497,11 +497,11 @@ public class Popover extends PopupControl { return switch (getArrowLocation()) { case LEFT_TOP, RIGHT_TOP -> getCornerRadius() + getArrowIndent() + getArrowSize(); case LEFT_CENTER, RIGHT_CENTER -> Math.max( - prefContentHeight, 2 * (getCornerRadius() + getArrowIndent() + getArrowSize()) + prefContentHeight, 2 * (getCornerRadius() + getArrowIndent() + getArrowSize()) ) / 2; case LEFT_BOTTOM, RIGHT_BOTTOM -> Math.max( - prefContentHeight - getCornerRadius() - getArrowIndent() - getArrowSize(), - getCornerRadius() + getArrowIndent() + getArrowSize() + prefContentHeight - getCornerRadius() - getArrowIndent() - getArrowSize(), + getCornerRadius() + getArrowIndent() + getArrowSize() ); default -> 0; }; @@ -531,7 +531,6 @@ public class Popover extends PopupControl { * Sets the value of the headerAlwaysVisible property. * * @param visible if true, then the header is visible even while attached - * * @see #headerAlwaysVisibleProperty() */ public final void setHeaderAlwaysVisible(boolean visible) { @@ -542,7 +541,6 @@ public class Popover extends PopupControl { * Returns the value of the detachable property. * * @return true if the header is visible even while attached - * * @see #headerAlwaysVisibleProperty() */ public final boolean isHeaderAlwaysVisible() { @@ -562,7 +560,6 @@ public class Popover extends PopupControl { * Sets the value of the closeButtonEnabled property. * * @param enabled if false, the popover will not be closeable by the header's close button - * * @see #closeButtonEnabledProperty() */ public final void setCloseButtonEnabled(boolean enabled) { @@ -573,7 +570,6 @@ public class Popover extends PopupControl { * Returns the value of the closeButtonEnabled property. * * @return true if the header's close button is enabled - * * @see #closeButtonEnabledProperty() */ public final boolean isCloseButtonEnabled() { @@ -593,7 +589,6 @@ public class Popover extends PopupControl { * Sets the value of the detachable property. * * @param detachable if true then the user can detach / tear off the popover - * * @see #detachableProperty() */ public final void setDetachable(boolean detachable) { @@ -604,7 +599,6 @@ public class Popover extends PopupControl { * Returns the value of the detachable property. * * @return true if the user is allowed to detach / tear off the popover - * * @see #detachableProperty() */ public final boolean isDetachable() { @@ -628,8 +622,7 @@ public class Popover extends PopupControl { * Sets the value of the detached property. * * @param detached if true the popover will change its appearance to "detached" - * mode - * + * mode * @see #detachedProperty() */ public final void setDetached(boolean detached) { @@ -640,7 +633,6 @@ public class Popover extends PopupControl { * Returns the value of the detached property. * * @return true if the popover is currently detached. - * * @see #detachedProperty() */ public final boolean isDetached() { @@ -662,7 +654,6 @@ public class Popover extends PopupControl { * Returns the value of the arrow size property. * * @return the arrow size property value - * * @see #arrowSizeProperty() */ public final double getArrowSize() { @@ -673,7 +664,6 @@ public class Popover extends PopupControl { * Sets the value of the arrow size property. * * @param size the new value of the arrow size property - * * @see #arrowSizeProperty() */ public final void setArrowSize(double size) { @@ -696,7 +686,6 @@ public class Popover extends PopupControl { * Returns the value of the arrow indent property. * * @return the arrow indent value - * * @see #arrowIndentProperty() */ public final double getArrowIndent() { @@ -707,7 +696,6 @@ public class Popover extends PopupControl { * Sets the value of the arrow indent property. * * @param size the arrow indent value - * * @see #arrowIndentProperty() */ public final void setArrowIndent(double size) { @@ -729,7 +717,6 @@ public class Popover extends PopupControl { * Returns the value of the corner radius property. * * @return the corner radius - * * @see #cornerRadiusProperty() */ public final double getCornerRadius() { @@ -740,7 +727,6 @@ public class Popover extends PopupControl { * Sets the value of the corner radius property. * * @param radius the corner radius - * * @see #cornerRadiusProperty() */ public final void setCornerRadius(double radius) { @@ -762,7 +748,6 @@ public class Popover extends PopupControl { * Returns the value of the title property. * * @return the detached title - * * @see #titleProperty() */ public final String getTitle() { @@ -773,7 +758,6 @@ public class Popover extends PopupControl { * Sets the value of the title property. * * @param title the title to use when detached - * * @see #titleProperty() */ public final void setTitle(String title) { @@ -783,14 +767,14 @@ public class Popover extends PopupControl { titleProperty().set(title); } - private final ObjectProperty arrowLocation = new SimpleObjectProperty<>(this, "arrowLocation", ArrowLocation.LEFT_TOP); + private final ObjectProperty arrowLocation = + new SimpleObjectProperty<>(this, "arrowLocation", ArrowLocation.LEFT_TOP); /** * Stores the preferred arrow location. This might not be the actual * location of the arrow if auto fix is enabled. * * @return the arrow location property - * * @see #setAutoFix(boolean) */ public final ObjectProperty arrowLocationProperty() { @@ -801,7 +785,6 @@ public class Popover extends PopupControl { * Sets the value of the arrow location property. * * @param location the requested location - * * @see #arrowLocationProperty() */ public final void setArrowLocation(ArrowLocation location) { @@ -812,7 +795,6 @@ public class Popover extends PopupControl { * Returns the value of the arrow location property. * * @return the preferred arrow location - * * @see #arrowLocationProperty() */ public final ArrowLocation getArrowLocation() { @@ -859,7 +841,6 @@ public class Popover extends PopupControl { * Returns the value of the fade-in duration property. * * @return the fade-in duration - * * @see #fadeInDurationProperty() */ public final Duration getFadeInDuration() { @@ -871,7 +852,6 @@ public class Popover extends PopupControl { * Popover.show(..). * * @param duration the requested fade-in duration - * * @see #fadeInDurationProperty() */ public final void setFadeInDuration(Duration duration) { @@ -882,7 +862,6 @@ public class Popover extends PopupControl { * Returns the value of the fade-out duration property. * * @return the fade-out duration - * * @see #fadeOutDurationProperty() */ public final Duration getFadeOutDuration() { @@ -893,7 +872,6 @@ public class Popover extends PopupControl { * Sets the value of the fade-out duration property. * * @param duration the requested fade-out duration - * * @see #fadeOutDurationProperty() */ public final void setFadeOutDuration(Duration duration) { @@ -914,7 +892,6 @@ public class Popover extends PopupControl { * Returns the value of the "animated" property. * * @return true if the Popover will be shown and hidden with a short fade animation - * * @see #animatedProperty() */ public final boolean isAnimated() { @@ -925,7 +902,6 @@ public class Popover extends PopupControl { * Sets the value of the "animated" property. * * @param animated if true the Popover will be shown and hidden with a short fade animation - * * @see #animatedProperty() */ public final void setAnimated(boolean animated) { diff --git a/base/src/main/java/atlantafx/base/controls/PopoverSkin.java b/base/src/main/java/atlantafx/base/controls/PopoverSkin.java index 13e783a..52e77f8 100755 --- a/base/src/main/java/atlantafx/base/controls/PopoverSkin.java +++ b/base/src/main/java/atlantafx/base/controls/PopoverSkin.java @@ -26,6 +26,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package atlantafx.base.controls; import static atlantafx.base.controls.Popover.ArrowLocation; @@ -90,12 +91,12 @@ public class PopoverSkin implements Skin { // the min width and height equal (2 * corner radius + 2 * arrow indent + 2 * arrow size) stackPane.minWidthProperty().bind( - Bindings.add(Bindings.multiply(2, popover.arrowSizeProperty()), - Bindings.add( - Bindings.multiply(2, popover.cornerRadiusProperty()), - Bindings.multiply(2, popover.arrowIndentProperty()) - ) + Bindings.add(Bindings.multiply(2, popover.arrowSizeProperty()), + Bindings.add( + Bindings.multiply(2, popover.cornerRadiusProperty()), + Bindings.multiply(2, popover.arrowIndentProperty()) ) + ) ); stackPane.minHeightProperty().bind(stackPane.minWidthProperty()); @@ -111,8 +112,8 @@ public class PopoverSkin implements Skin { closeIcon.setMaxSize(MAX_VALUE, MAX_VALUE); closeIcon.setContentDisplay(GRAPHIC_ONLY); closeIcon.visibleProperty().bind( - popover.closeButtonEnabledProperty().and( - popover.detachedProperty().or(popover.headerAlwaysVisibleProperty()))); + popover.closeButtonEnabledProperty().and( + popover.detachedProperty().or(popover.headerAlwaysVisibleProperty()))); closeIcon.getStyleClass().add("icon"); closeIcon.setAlignment(TOP_RIGHT); closeIcon.getGraphic().setOnMouseClicked(evt -> popover.hide()); @@ -156,10 +157,10 @@ public class PopoverSkin implements Skin { switch (getSkinnable().getArrowLocation()) { case LEFT_TOP, LEFT_CENTER, LEFT_BOTTOM -> popover.setAnchorX( - popover.getAnchorX() + popover.getArrowSize() + popover.getAnchorX() + popover.getArrowSize() ); case TOP_LEFT, TOP_CENTER, TOP_RIGHT -> popover.setAnchorY( - popover.getAnchorY() + popover.getArrowSize() + popover.getAnchorY() + popover.getArrowSize() ); } } else { @@ -252,7 +253,8 @@ public class PopoverSkin implements Skin { } @Override - public void dispose() { } + public void dispose() { + } private Node createCloseIcon() { Group group = new Group(); @@ -293,15 +295,15 @@ public class PopoverSkin implements Skin { private VLineTo lineBRight, lineERight, lineHRight, lineKRight; private LineTo lineCRight, lineDRight, lineFRight, lineGRight, lineIRight, - lineJRight; + lineJRight; private HLineTo lineBBottom, lineEBottom, lineHBottom, lineKBottom; private LineTo lineCBottom, lineDBottom, lineFBottom, lineGBottom, - lineIBottom, lineJBottom; + lineIBottom, lineJBottom; private VLineTo lineBLeft, lineELeft, lineHLeft, lineKLeft; private LineTo lineCLeft, lineDLeft, lineFLeft, lineGLeft, lineILeft, - lineJLeft; + lineJLeft; private void createPathElements() { DoubleProperty centerYProperty = new SimpleDoubleProperty(); @@ -323,24 +325,24 @@ public class PopoverSkin implements Skin { DoubleProperty arrowSizeProperty = getSkinnable().arrowSizeProperty(); DoubleProperty arrowIndentProperty = getSkinnable() - .arrowIndentProperty(); + .arrowIndentProperty(); centerYProperty.bind(Bindings.divide(stackPane.heightProperty(), 2)); centerXProperty.bind(Bindings.divide(stackPane.widthProperty(), 2)); leftEdgePlusRadiusProperty.bind(Bindings.add(leftEdgeProperty, - getSkinnable().cornerRadiusProperty())); + getSkinnable().cornerRadiusProperty())); topEdgePlusRadiusProperty.bind(Bindings.add(topEdgeProperty, - getSkinnable().cornerRadiusProperty())); + getSkinnable().cornerRadiusProperty())); rightEdgeProperty.bind(stackPane.widthProperty()); rightEdgeMinusRadiusProperty.bind(Bindings.subtract(rightEdgeProperty, - getSkinnable().cornerRadiusProperty())); + getSkinnable().cornerRadiusProperty())); bottomEdgeProperty.bind(stackPane.heightProperty()); bottomEdgeMinusRadiusProperty.bind(Bindings.subtract( - bottomEdgeProperty, getSkinnable().cornerRadiusProperty())); + bottomEdgeProperty, getSkinnable().cornerRadiusProperty())); // == INIT == moveTo = new MoveTo(); @@ -350,51 +352,51 @@ public class PopoverSkin implements Skin { // == TOP EDGE == lineBTop = new HLineTo(); lineBTop.xProperty().bind( - Bindings.add(leftEdgePlusRadiusProperty, arrowIndentProperty)); + Bindings.add(leftEdgePlusRadiusProperty, arrowIndentProperty)); lineCTop = new LineTo(); lineCTop.xProperty().bind( - Bindings.add(lineBTop.xProperty(), arrowSizeProperty)); + Bindings.add(lineBTop.xProperty(), arrowSizeProperty)); lineCTop.yProperty().bind( - Bindings.subtract(topEdgeProperty, arrowSizeProperty)); + Bindings.subtract(topEdgeProperty, arrowSizeProperty)); lineDTop = new LineTo(); lineDTop.xProperty().bind( - Bindings.add(lineCTop.xProperty(), arrowSizeProperty)); + Bindings.add(lineCTop.xProperty(), arrowSizeProperty)); lineDTop.yProperty().bind(topEdgeProperty); lineETop = new HLineTo(); lineETop.xProperty().bind( - Bindings.subtract(centerXProperty, arrowSizeProperty)); + Bindings.subtract(centerXProperty, arrowSizeProperty)); lineFTop = new LineTo(); lineFTop.xProperty().bind(centerXProperty); lineFTop.yProperty().bind( - Bindings.subtract(topEdgeProperty, arrowSizeProperty)); + Bindings.subtract(topEdgeProperty, arrowSizeProperty)); lineGTop = new LineTo(); lineGTop.xProperty().bind( - Bindings.add(centerXProperty, arrowSizeProperty)); + Bindings.add(centerXProperty, arrowSizeProperty)); lineGTop.yProperty().bind(topEdgeProperty); lineHTop = new HLineTo(); lineHTop.xProperty().bind( - Bindings.subtract(Bindings.subtract( - rightEdgeMinusRadiusProperty, arrowIndentProperty), - Bindings.multiply(arrowSizeProperty, 2))); + Bindings.subtract(Bindings.subtract( + rightEdgeMinusRadiusProperty, arrowIndentProperty), + Bindings.multiply(arrowSizeProperty, 2))); lineITop = new LineTo(); lineITop.xProperty().bind( - Bindings.subtract(Bindings.subtract( - rightEdgeMinusRadiusProperty, arrowIndentProperty), - arrowSizeProperty)); + Bindings.subtract(Bindings.subtract( + rightEdgeMinusRadiusProperty, arrowIndentProperty), + arrowSizeProperty)); lineITop.yProperty().bind( - Bindings.subtract(topEdgeProperty, arrowSizeProperty)); + Bindings.subtract(topEdgeProperty, arrowSizeProperty)); lineJTop = new LineTo(); lineJTop.xProperty().bind( - Bindings.subtract(rightEdgeMinusRadiusProperty, - arrowIndentProperty)); + Bindings.subtract(rightEdgeMinusRadiusProperty, + arrowIndentProperty)); lineJTop.yProperty().bind(topEdgeProperty); lineKTop = new HLineTo(); @@ -404,58 +406,58 @@ public class PopoverSkin implements Skin { rightCurveTo = new QuadCurveTo(); rightCurveTo.xProperty().bind(rightEdgeProperty); rightCurveTo.yProperty().bind( - Bindings.add(topEdgeProperty, cornerProperty)); + Bindings.add(topEdgeProperty, cornerProperty)); rightCurveTo.controlXProperty().bind(rightEdgeProperty); rightCurveTo.controlYProperty().bind(topEdgeProperty); lineBRight = new VLineTo(); lineBRight.yProperty().bind( - Bindings.add(topEdgePlusRadiusProperty, arrowIndentProperty)); + Bindings.add(topEdgePlusRadiusProperty, arrowIndentProperty)); lineCRight = new LineTo(); lineCRight.xProperty().bind( - Bindings.add(rightEdgeProperty, arrowSizeProperty)); + Bindings.add(rightEdgeProperty, arrowSizeProperty)); lineCRight.yProperty().bind( - Bindings.add(lineBRight.yProperty(), arrowSizeProperty)); + Bindings.add(lineBRight.yProperty(), arrowSizeProperty)); lineDRight = new LineTo(); lineDRight.xProperty().bind(rightEdgeProperty); lineDRight.yProperty().bind( - Bindings.add(lineCRight.yProperty(), arrowSizeProperty)); + Bindings.add(lineCRight.yProperty(), arrowSizeProperty)); lineERight = new VLineTo(); lineERight.yProperty().bind( - Bindings.subtract(centerYProperty, arrowSizeProperty)); + Bindings.subtract(centerYProperty, arrowSizeProperty)); lineFRight = new LineTo(); lineFRight.xProperty().bind( - Bindings.add(rightEdgeProperty, arrowSizeProperty)); + Bindings.add(rightEdgeProperty, arrowSizeProperty)); lineFRight.yProperty().bind(centerYProperty); lineGRight = new LineTo(); lineGRight.xProperty().bind(rightEdgeProperty); lineGRight.yProperty().bind( - Bindings.add(centerYProperty, arrowSizeProperty)); + Bindings.add(centerYProperty, arrowSizeProperty)); lineHRight = new VLineTo(); lineHRight.yProperty().bind( - Bindings.subtract(Bindings.subtract( - bottomEdgeMinusRadiusProperty, arrowIndentProperty), - Bindings.multiply(arrowSizeProperty, 2))); + Bindings.subtract(Bindings.subtract( + bottomEdgeMinusRadiusProperty, arrowIndentProperty), + Bindings.multiply(arrowSizeProperty, 2))); lineIRight = new LineTo(); lineIRight.xProperty().bind( - Bindings.add(rightEdgeProperty, arrowSizeProperty)); + Bindings.add(rightEdgeProperty, arrowSizeProperty)); lineIRight.yProperty().bind( - Bindings.subtract(Bindings.subtract( - bottomEdgeMinusRadiusProperty, arrowIndentProperty), - arrowSizeProperty)); + Bindings.subtract(Bindings.subtract( + bottomEdgeMinusRadiusProperty, arrowIndentProperty), + arrowSizeProperty)); lineJRight = new LineTo(); lineJRight.xProperty().bind(rightEdgeProperty); lineJRight.yProperty().bind( - Bindings.subtract(bottomEdgeMinusRadiusProperty, - arrowIndentProperty)); + Bindings.subtract(bottomEdgeMinusRadiusProperty, + arrowIndentProperty)); lineKRight = new VLineTo(); lineKRight.yProperty().bind(bottomEdgeMinusRadiusProperty); @@ -469,50 +471,50 @@ public class PopoverSkin implements Skin { lineBBottom = new HLineTo(); lineBBottom.xProperty().bind( - Bindings.subtract(rightEdgeMinusRadiusProperty, - arrowIndentProperty)); + Bindings.subtract(rightEdgeMinusRadiusProperty, + arrowIndentProperty)); lineCBottom = new LineTo(); lineCBottom.xProperty().bind( - Bindings.subtract(lineBBottom.xProperty(), arrowSizeProperty)); + Bindings.subtract(lineBBottom.xProperty(), arrowSizeProperty)); lineCBottom.yProperty().bind( - Bindings.add(bottomEdgeProperty, arrowSizeProperty)); + Bindings.add(bottomEdgeProperty, arrowSizeProperty)); lineDBottom = new LineTo(); lineDBottom.xProperty().bind( - Bindings.subtract(lineCBottom.xProperty(), arrowSizeProperty)); + Bindings.subtract(lineCBottom.xProperty(), arrowSizeProperty)); lineDBottom.yProperty().bind(bottomEdgeProperty); lineEBottom = new HLineTo(); lineEBottom.xProperty().bind( - Bindings.add(centerXProperty, arrowSizeProperty)); + Bindings.add(centerXProperty, arrowSizeProperty)); lineFBottom = new LineTo(); lineFBottom.xProperty().bind(centerXProperty); lineFBottom.yProperty().bind( - Bindings.add(bottomEdgeProperty, arrowSizeProperty)); + Bindings.add(bottomEdgeProperty, arrowSizeProperty)); lineGBottom = new LineTo(); lineGBottom.xProperty().bind( - Bindings.subtract(centerXProperty, arrowSizeProperty)); + Bindings.subtract(centerXProperty, arrowSizeProperty)); lineGBottom.yProperty().bind(bottomEdgeProperty); lineHBottom = new HLineTo(); lineHBottom.xProperty().bind( - Bindings.add(Bindings.add(leftEdgePlusRadiusProperty, - arrowIndentProperty), Bindings.multiply( - arrowSizeProperty, 2))); + Bindings.add(Bindings.add(leftEdgePlusRadiusProperty, + arrowIndentProperty), Bindings.multiply( + arrowSizeProperty, 2))); lineIBottom = new LineTo(); lineIBottom.xProperty().bind( - Bindings.add(Bindings.add(leftEdgePlusRadiusProperty, - arrowIndentProperty), arrowSizeProperty)); + Bindings.add(Bindings.add(leftEdgePlusRadiusProperty, + arrowIndentProperty), arrowSizeProperty)); lineIBottom.yProperty().bind( - Bindings.add(bottomEdgeProperty, arrowSizeProperty)); + Bindings.add(bottomEdgeProperty, arrowSizeProperty)); lineJBottom = new LineTo(); lineJBottom.xProperty().bind( - Bindings.add(leftEdgePlusRadiusProperty, arrowIndentProperty)); + Bindings.add(leftEdgePlusRadiusProperty, arrowIndentProperty)); lineJBottom.yProperty().bind(bottomEdgeProperty); lineKBottom = new HLineTo(); @@ -522,57 +524,57 @@ public class PopoverSkin implements Skin { leftCurveTo = new QuadCurveTo(); leftCurveTo.xProperty().bind(leftEdgeProperty); leftCurveTo.yProperty().bind( - Bindings.subtract(bottomEdgeProperty, cornerProperty)); + Bindings.subtract(bottomEdgeProperty, cornerProperty)); leftCurveTo.controlXProperty().bind(leftEdgeProperty); leftCurveTo.controlYProperty().bind(bottomEdgeProperty); lineBLeft = new VLineTo(); lineBLeft.yProperty().bind( - Bindings.subtract(bottomEdgeMinusRadiusProperty, - arrowIndentProperty)); + Bindings.subtract(bottomEdgeMinusRadiusProperty, + arrowIndentProperty)); lineCLeft = new LineTo(); lineCLeft.xProperty().bind( - Bindings.subtract(leftEdgeProperty, arrowSizeProperty)); + Bindings.subtract(leftEdgeProperty, arrowSizeProperty)); lineCLeft.yProperty().bind( - Bindings.subtract(lineBLeft.yProperty(), arrowSizeProperty)); + Bindings.subtract(lineBLeft.yProperty(), arrowSizeProperty)); lineDLeft = new LineTo(); lineDLeft.xProperty().bind(leftEdgeProperty); lineDLeft.yProperty().bind( - Bindings.subtract(lineCLeft.yProperty(), arrowSizeProperty)); + Bindings.subtract(lineCLeft.yProperty(), arrowSizeProperty)); lineELeft = new VLineTo(); lineELeft.yProperty().bind( - Bindings.add(centerYProperty, arrowSizeProperty)); + Bindings.add(centerYProperty, arrowSizeProperty)); lineFLeft = new LineTo(); lineFLeft.xProperty().bind( - Bindings.subtract(leftEdgeProperty, arrowSizeProperty)); + Bindings.subtract(leftEdgeProperty, arrowSizeProperty)); lineFLeft.yProperty().bind(centerYProperty); lineGLeft = new LineTo(); lineGLeft.xProperty().bind(leftEdgeProperty); lineGLeft.yProperty().bind( - Bindings.subtract(centerYProperty, arrowSizeProperty)); + Bindings.subtract(centerYProperty, arrowSizeProperty)); lineHLeft = new VLineTo(); lineHLeft.yProperty().bind( - Bindings.add(Bindings.add(topEdgePlusRadiusProperty, - arrowIndentProperty), Bindings.multiply( - arrowSizeProperty, 2))); + Bindings.add(Bindings.add(topEdgePlusRadiusProperty, + arrowIndentProperty), Bindings.multiply( + arrowSizeProperty, 2))); lineILeft = new LineTo(); lineILeft.xProperty().bind( - Bindings.subtract(leftEdgeProperty, arrowSizeProperty)); + Bindings.subtract(leftEdgeProperty, arrowSizeProperty)); lineILeft.yProperty().bind( - Bindings.add(Bindings.add(topEdgePlusRadiusProperty, - arrowIndentProperty), arrowSizeProperty)); + Bindings.add(Bindings.add(topEdgePlusRadiusProperty, + arrowIndentProperty), arrowSizeProperty)); lineJLeft = new LineTo(); lineJLeft.xProperty().bind(leftEdgeProperty); lineJLeft.yProperty().bind( - Bindings.add(topEdgePlusRadiusProperty, arrowIndentProperty)); + Bindings.add(topEdgePlusRadiusProperty, arrowIndentProperty)); lineKLeft = new VLineTo(); lineKLeft.yProperty().bind(topEdgePlusRadiusProperty); diff --git a/base/src/main/java/atlantafx/base/controls/ProgressSliderSkin.java b/base/src/main/java/atlantafx/base/controls/ProgressSliderSkin.java index 22e0a22..653c844 100644 --- a/base/src/main/java/atlantafx/base/controls/ProgressSliderSkin.java +++ b/base/src/main/java/atlantafx/base/controls/ProgressSliderSkin.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.base.controls; import javafx.geometry.Orientation; @@ -6,7 +7,9 @@ import javafx.scene.control.Slider; import javafx.scene.control.skin.SliderSkin; import javafx.scene.layout.StackPane; -/** {@link Slider} skin that supports progress color. */ +/** + * {@link Slider} skin that supports progress color. + */ public class ProgressSliderSkin extends SliderSkin { protected final StackPane thumb; @@ -45,7 +48,8 @@ public class ProgressSliderSkin extends SliderSkin { } else { progressY = thumb.getLayoutY(); progressWidth = track.getWidth(); - progressHeight = track.getLayoutBounds().getMaxY() + track.getLayoutY() - thumb.getLayoutY() - snappedBottomInset(); + progressHeight = + track.getLayoutBounds().getMaxY() + track.getLayoutY() - thumb.getLayoutY() - snappedBottomInset(); } progressTrack.resizeRelocate(progressX, progressY, progressWidth, progressHeight); diff --git a/base/src/main/java/atlantafx/base/controls/RingProgressIndicator.java b/base/src/main/java/atlantafx/base/controls/RingProgressIndicator.java index da552b3..d177e4f 100755 --- a/base/src/main/java/atlantafx/base/controls/RingProgressIndicator.java +++ b/base/src/main/java/atlantafx/base/controls/RingProgressIndicator.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.base.controls; import javafx.beans.property.ObjectProperty; @@ -12,7 +13,8 @@ import javafx.util.StringConverter; public class RingProgressIndicator extends ProgressIndicator { - public RingProgressIndicator() { } + public RingProgressIndicator() { + } public RingProgressIndicator(double progress) { this(progress, false); @@ -52,7 +54,8 @@ public class RingProgressIndicator extends ProgressIndicator { // ~ - protected final ObjectProperty> stringConverter = new SimpleObjectProperty<>(this, "converter", null); + protected final ObjectProperty> stringConverter = + new SimpleObjectProperty<>(this, "converter", null); public StringConverter getStringConverter() { return stringConverterProperty().get(); @@ -62,7 +65,9 @@ public class RingProgressIndicator extends ProgressIndicator { this.stringConverterProperty().set(stringConverter); } - /** Optional converter to transform progress value to string. */ + /** + * Optional converter to transform progress value to string. + */ public ObjectProperty> stringConverterProperty() { return stringConverter; } diff --git a/base/src/main/java/atlantafx/base/controls/RingProgressIndicatorSkin.java b/base/src/main/java/atlantafx/base/controls/RingProgressIndicatorSkin.java index 10d2564..d74651f 100755 --- a/base/src/main/java/atlantafx/base/controls/RingProgressIndicatorSkin.java +++ b/base/src/main/java/atlantafx/base/controls/RingProgressIndicatorSkin.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.base.controls; import java.util.ArrayList; @@ -33,7 +34,7 @@ public class RingProgressIndicatorSkin extends SkinBase { protected final Arc progressArc = new Arc(); protected final Label progressLabel = new Label(); protected final RotateTransition transition = new RotateTransition( - Duration.seconds(DEFAULT_ANIMATION_TIME), progressArc + Duration.seconds(DEFAULT_ANIMATION_TIME), progressArc ); public RingProgressIndicatorSkin(RingProgressIndicator indicator) { @@ -230,26 +231,27 @@ public class RingProgressIndicatorSkin extends SkinBase { private static class StyleableProperties { private static final CssMetaData INDETERMINATE_ANIMATION_TIME = - new CssMetaData<>("-fx-indeterminate-animation-time", SizeConverter.getInstance(), DEFAULT_ANIMATION_TIME) { + new CssMetaData<>("-fx-indeterminate-animation-time", SizeConverter.getInstance(), DEFAULT_ANIMATION_TIME) { - @Override - public boolean isSettable(RingProgressIndicator n) { - return n.getSkin() instanceof RingProgressIndicatorSkin s && - (s.indeterminateAnimationTime == null || !s.indeterminateAnimationTime.isBound()); - } + @Override + public boolean isSettable(RingProgressIndicator n) { + return n.getSkin() instanceof RingProgressIndicatorSkin s && + (s.indeterminateAnimationTime == null || !s.indeterminateAnimationTime.isBound()); + } - @Override - @SuppressWarnings("RedundantCast") - public StyleableProperty getStyleableProperty(RingProgressIndicator n) { - final RingProgressIndicatorSkin skin = (RingProgressIndicatorSkin) n.getSkin(); - return (StyleableProperty) (WritableValue) skin.indeterminateAnimationTimeProperty(); - } - }; + @Override + @SuppressWarnings("RedundantCast") + public StyleableProperty getStyleableProperty(RingProgressIndicator n) { + final RingProgressIndicatorSkin skin = (RingProgressIndicatorSkin) n.getSkin(); + return (StyleableProperty) (WritableValue) skin.indeterminateAnimationTimeProperty(); + } + }; private static final List> STYLEABLES; static { - final List> styleables = new ArrayList<>(SkinBase.getClassCssMetaData()); + final List> styleables = + new ArrayList<>(SkinBase.getClassCssMetaData()); styleables.add(INDETERMINATE_ANIMATION_TIME); STYLEABLES = Collections.unmodifiableList(styleables); } diff --git a/base/src/main/java/atlantafx/base/controls/Spacer.java b/base/src/main/java/atlantafx/base/controls/Spacer.java index f826e73..f143109 100644 --- a/base/src/main/java/atlantafx/base/controls/Spacer.java +++ b/base/src/main/java/atlantafx/base/controls/Spacer.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.base.controls; import javafx.geometry.Orientation; diff --git a/base/src/main/java/atlantafx/base/controls/ToggleSwitch.java b/base/src/main/java/atlantafx/base/controls/ToggleSwitch.java index 67a4d94..ecdaac6 100755 --- a/base/src/main/java/atlantafx/base/controls/ToggleSwitch.java +++ b/base/src/main/java/atlantafx/base/controls/ToggleSwitch.java @@ -26,6 +26,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package atlantafx.base.controls; import javafx.beans.property.BooleanProperty; @@ -41,7 +42,9 @@ public class ToggleSwitch extends Labeled { protected static final String DEFAULT_STYLE_CLASS = "toggle-switch"; protected static final PseudoClass PSEUDO_CLASS_SELECTED = PseudoClass.getPseudoClass("selected"); - /** Creates a toggle switch with empty string for its label. */ + /** + * Creates a toggle switch with empty string for its label. + */ public ToggleSwitch() { initialize(); } @@ -64,20 +67,28 @@ public class ToggleSwitch extends Labeled { // Properties // /////////////////////////////////////////////////////////////////////////// - /** Indicates whether this switch is selected. */ + /** + * Indicates whether this switch is selected. + */ private BooleanProperty selected; - /** Sets the selected value. */ + /** + * Sets the selected value. + */ public final void setSelected(boolean value) { selectedProperty().set(value); } - /** Returns whether this Toggle Switch is selected. */ + /** + * Returns whether this Toggle Switch is selected. + */ public final boolean isSelected() { return selected != null && selected.get(); } - /** Returns the selected property. */ + /** + * Returns the selected property. + */ public final BooleanProperty selectedProperty() { if (selected == null) { selected = new BooleanPropertyBase() { @@ -117,7 +128,9 @@ public class ToggleSwitch extends Labeled { } } - /** {@inheritDoc} */ + /** + * {@inheritDoc} + */ @Override protected Skin createDefaultSkin() { return new ToggleSwitchSkin(this); diff --git a/base/src/main/java/atlantafx/base/controls/ToggleSwitchSkin.java b/base/src/main/java/atlantafx/base/controls/ToggleSwitchSkin.java index ff58633..e55ee90 100755 --- a/base/src/main/java/atlantafx/base/controls/ToggleSwitchSkin.java +++ b/base/src/main/java/atlantafx/base/controls/ToggleSwitchSkin.java @@ -26,6 +26,7 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ + package atlantafx.base.controls; import java.util.ArrayList; @@ -76,8 +77,9 @@ public class ToggleSwitchSkin extends SkinBase { thumbArea.setOnMouseReleased(event -> mousePressedOnToggleSwitch(control)); thumb.setOnMouseReleased(event -> mousePressedOnToggleSwitch(control)); control.selectedProperty().addListener((observable, oldValue, newValue) -> { - if (newValue.booleanValue() != oldValue.booleanValue()) + if (newValue.booleanValue() != oldValue.booleanValue()) { selectedStateChanged(); + } }); } @@ -206,21 +208,21 @@ public class ToggleSwitchSkin extends SkinBase { } private static final CssMetaData THUMB_MOVE_ANIMATION_TIME = - new CssMetaData<>("-fx-thumb-move-animation-time", SizeConverter.getInstance(), 200) { + new CssMetaData<>("-fx-thumb-move-animation-time", SizeConverter.getInstance(), 200) { - @Override - public boolean isSettable(ToggleSwitch toggleSwitch) { - final ToggleSwitchSkin skin = (ToggleSwitchSkin) toggleSwitch.getSkin(); - return skin.thumbMoveAnimationTime == null || skin.thumbMoveAnimationTime.isBound(); - } + @Override + public boolean isSettable(ToggleSwitch toggleSwitch) { + final ToggleSwitchSkin skin = (ToggleSwitchSkin) toggleSwitch.getSkin(); + return skin.thumbMoveAnimationTime == null || skin.thumbMoveAnimationTime.isBound(); + } - @Override - @SuppressWarnings("RedundantCast") - public StyleableProperty getStyleableProperty(ToggleSwitch toggleSwitch) { - final ToggleSwitchSkin skin = (ToggleSwitchSkin) toggleSwitch.getSkin(); - return (StyleableProperty) (WritableValue) skin.thumbMoveAnimationTimeProperty(); - } - }; + @Override + @SuppressWarnings("RedundantCast") + public StyleableProperty getStyleableProperty(ToggleSwitch toggleSwitch) { + final ToggleSwitchSkin skin = (ToggleSwitchSkin) toggleSwitch.getSkin(); + return (StyleableProperty) (WritableValue) skin.thumbMoveAnimationTimeProperty(); + } + }; private static final List> STYLEABLES; diff --git a/base/src/main/java/atlantafx/base/theme/NordDark.java b/base/src/main/java/atlantafx/base/theme/NordDark.java index 0985369..e3b8a79 100755 --- a/base/src/main/java/atlantafx/base/theme/NordDark.java +++ b/base/src/main/java/atlantafx/base/theme/NordDark.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.base.theme; public final class NordDark implements Theme { diff --git a/base/src/main/java/atlantafx/base/theme/NordLight.java b/base/src/main/java/atlantafx/base/theme/NordLight.java index 8339a22..3c1fc3d 100755 --- a/base/src/main/java/atlantafx/base/theme/NordLight.java +++ b/base/src/main/java/atlantafx/base/theme/NordLight.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.base.theme; public final class NordLight implements Theme { diff --git a/base/src/main/java/atlantafx/base/theme/PrimerDark.java b/base/src/main/java/atlantafx/base/theme/PrimerDark.java index 64c4f10..1e85c87 100755 --- a/base/src/main/java/atlantafx/base/theme/PrimerDark.java +++ b/base/src/main/java/atlantafx/base/theme/PrimerDark.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.base.theme; public final class PrimerDark implements Theme { diff --git a/base/src/main/java/atlantafx/base/theme/PrimerLight.java b/base/src/main/java/atlantafx/base/theme/PrimerLight.java index 9620a2e..e3e734f 100755 --- a/base/src/main/java/atlantafx/base/theme/PrimerLight.java +++ b/base/src/main/java/atlantafx/base/theme/PrimerLight.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.base.theme; public final class PrimerLight implements Theme { diff --git a/base/src/main/java/atlantafx/base/theme/Styles.java b/base/src/main/java/atlantafx/base/theme/Styles.java index 2e880f3..3c6730f 100644 --- a/base/src/main/java/atlantafx/base/theme/Styles.java +++ b/base/src/main/java/atlantafx/base/theme/Styles.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.base.theme; import javafx.css.PseudoClass; @@ -83,10 +84,12 @@ public final class Styles { } public static void toggleStyleClass(Node node, String styleClass) { - if (node == null) + if (node == null) { throw new NullPointerException("Node cannot be null!"); - if (styleClass == null) + } + if (styleClass == null) { throw new NullPointerException("Style class cannot be null!"); + } int idx = node.getStyleClass().indexOf(styleClass); if (idx > 0) { @@ -97,10 +100,12 @@ public final class Styles { } public static void addStyleClass(Node node, String styleClass, String... excludes) { - if (node == null) + if (node == null) { throw new NullPointerException("Node cannot be null!"); - if (styleClass == null) + } + if (styleClass == null) { throw new NullPointerException("Style class cannot be null!"); + } if (excludes != null && excludes.length > 0) { node.getStyleClass().removeAll(excludes); @@ -109,10 +114,12 @@ public final class Styles { } public static void activatePseudoClass(Node node, PseudoClass pseudoClass, PseudoClass... excludes) { - if (node == null) + if (node == null) { throw new NullPointerException("Node cannot be null!"); - if (pseudoClass == null) + } + if (pseudoClass == null) { throw new NullPointerException("PseudoClass cannot be null!"); + } if (excludes != null && excludes.length > 0) { for (PseudoClass exclude : excludes) { diff --git a/base/src/main/java/atlantafx/base/theme/Theme.java b/base/src/main/java/atlantafx/base/theme/Theme.java index 25b450a..5aabb2a 100755 --- a/base/src/main/java/atlantafx/base/theme/Theme.java +++ b/base/src/main/java/atlantafx/base/theme/Theme.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.base.theme; import static javafx.application.Application.STYLESHEET_CASPIAN; @@ -16,10 +17,12 @@ public interface Theme { boolean isDarkMode(); static Theme of(final String name, final String userAgentStylesheet, final boolean darkMode) { - if (name == null) + if (name == null) { throw new NullPointerException("Name cannot be null!"); - if (userAgentStylesheet == null) + } + if (userAgentStylesheet == null) { throw new NullPointerException("User agent stylesheet cannot be null!"); + } return new Theme() { @@ -41,6 +44,7 @@ public interface Theme { } default boolean isDefault() { - return STYLESHEET_MODENA.equals(getUserAgentStylesheet()) || STYLESHEET_CASPIAN.equals(getUserAgentStylesheet()); + return STYLESHEET_MODENA.equals(getUserAgentStylesheet()) || + STYLESHEET_CASPIAN.equals(getUserAgentStylesheet()); } } diff --git a/base/src/main/java/atlantafx/base/util/DoubleStringConverter.java b/base/src/main/java/atlantafx/base/util/DoubleStringConverter.java index 8c7c0fa..d166d36 100644 --- a/base/src/main/java/atlantafx/base/util/DoubleStringConverter.java +++ b/base/src/main/java/atlantafx/base/util/DoubleStringConverter.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.base.util; import java.text.DecimalFormat; @@ -125,15 +126,15 @@ public class DoubleStringConverter extends StringConverter { */ public static DoubleStringConverter createFor(Spinner spinner) { final SpinnerValueFactory.DoubleSpinnerValueFactory factory = - (SpinnerValueFactory.DoubleSpinnerValueFactory) spinner.getValueFactory(); + (SpinnerValueFactory.DoubleSpinnerValueFactory) spinner.getValueFactory(); final DoubleStringConverter converter = new DoubleStringConverter( - spinner.getEditor(), factory.getMin(), factory.getMax()); + spinner.getEditor(), factory.getMin(), factory.getMax()); factory.setConverter(converter); spinner.setTooltip(new Tooltip(String.format( - "Enter a value between %.2f and %.2f", - factory.getMin(), factory.getMax()))); + "Enter a value between %.2f and %.2f", + factory.getMin(), factory.getMax()))); return converter; } diff --git a/base/src/main/java/atlantafx/base/util/IntegerStringConverter.java b/base/src/main/java/atlantafx/base/util/IntegerStringConverter.java index 0c60c78..e5702a2 100644 --- a/base/src/main/java/atlantafx/base/util/IntegerStringConverter.java +++ b/base/src/main/java/atlantafx/base/util/IntegerStringConverter.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.base.util; import javafx.application.Platform; @@ -119,15 +120,15 @@ public class IntegerStringConverter extends StringConverter { */ public static IntegerStringConverter createFor(Spinner spinner) { final SpinnerValueFactory.IntegerSpinnerValueFactory factory = - (SpinnerValueFactory.IntegerSpinnerValueFactory) spinner.getValueFactory(); + (SpinnerValueFactory.IntegerSpinnerValueFactory) spinner.getValueFactory(); final IntegerStringConverter converter = new IntegerStringConverter( - spinner.getEditor(), factory.getMin(), factory.getMax()); + spinner.getEditor(), factory.getMin(), factory.getMax()); factory.setConverter(converter); spinner.setTooltip(new Tooltip(String.format( - "Enter a value between %d and %d", - factory.getMin(), factory.getMax()))); + "Enter a value between %d and %d", + factory.getMin(), factory.getMax()))); return converter; } diff --git a/base/src/main/java/atlantafx/base/util/PasswordTextFormatter.java b/base/src/main/java/atlantafx/base/util/PasswordTextFormatter.java index 98fbc4f..b63f027 100644 --- a/base/src/main/java/atlantafx/base/util/PasswordTextFormatter.java +++ b/base/src/main/java/atlantafx/base/util/PasswordTextFormatter.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.base.util; import java.util.function.UnaryOperator; @@ -25,19 +26,24 @@ public class PasswordTextFormatter extends TextFormatter { char bullet) { super(valueConverter, null, filter); - if (valueConverter == null) + if (valueConverter == null) { throw new NullPointerException("StringConverter cannot be null!"); - if (filter == null) + } + if (filter == null) { throw new NullPointerException("UnaryOperator cannot be null!"); - if (textField == null) + } + if (textField == null) { throw new NullPointerException("TextField cannot be null!"); + } PasswordFilter passwordFilter = (PasswordFilter) getFilter(); passwordFilter.setBullet(bullet); passwordFilter.setInitialText(textField.getText()); revealPasswordProperty().addListener((obs, old, val) -> { - if (val == null) { return; } + if (val == null) { + return; + } // Force text field update, because converter is only called on focus events by default. // Also, reset caret first, because otherwise its position won't be correct due to diff --git a/base/src/main/java/atlantafx/base/util/PlatformUtils.java b/base/src/main/java/atlantafx/base/util/PlatformUtils.java index aa8b0aa..0a36306 100755 --- a/base/src/main/java/atlantafx/base/util/PlatformUtils.java +++ b/base/src/main/java/atlantafx/base/util/PlatformUtils.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.base.util; /** diff --git a/base/src/test/java/atlantafx/base/util/PasswordTextFormatterTest.java b/base/src/test/java/atlantafx/base/util/PasswordTextFormatterTest.java index 5c43cb0..b5d7905 100644 --- a/base/src/test/java/atlantafx/base/util/PasswordTextFormatterTest.java +++ b/base/src/test/java/atlantafx/base/util/PasswordTextFormatterTest.java @@ -12,7 +12,8 @@ public class PasswordTextFormatterTest { @BeforeAll public static void startup() { - Platform.startup(() -> { }); + Platform.startup(() -> { + }); } @Test diff --git a/sampler/src/main/java/atlantafx/sampler/DefaultExceptionHandler.java b/sampler/src/main/java/atlantafx/sampler/DefaultExceptionHandler.java index 40ee36a..f091a41 100644 --- a/sampler/src/main/java/atlantafx/sampler/DefaultExceptionHandler.java +++ b/sampler/src/main/java/atlantafx/sampler/DefaultExceptionHandler.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler; import static java.lang.Double.MAX_VALUE; @@ -27,7 +28,9 @@ public class DefaultExceptionHandler implements Thread.UncaughtExceptionHandler e.printStackTrace(); var dialog = createExceptionDialog(e); - if (dialog != null) { dialog.showAndWait(); } + if (dialog != null) { + dialog.showAndWait(); + } } private Alert createExceptionDialog(Throwable throwable) { diff --git a/sampler/src/main/java/atlantafx/sampler/FileResource.java b/sampler/src/main/java/atlantafx/sampler/FileResource.java index 38757eb..9a19fdb 100644 --- a/sampler/src/main/java/atlantafx/sampler/FileResource.java +++ b/sampler/src/main/java/atlantafx/sampler/FileResource.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler; import java.io.FileInputStream; @@ -50,7 +51,9 @@ public final class FileResource { public InputStream getInputStream() throws IOException { if (internal) { var is = anchor.getResourceAsStream(location); - if (is == null) { throw new IOException("Resource not found: " + location); } + if (is == null) { + throw new IOException("Resource not found: " + location); + } return is; } return new FileInputStream(toPath().toFile()); diff --git a/sampler/src/main/java/atlantafx/sampler/Launcher.java b/sampler/src/main/java/atlantafx/sampler/Launcher.java index 4e1ffba..dae0d92 100755 --- a/sampler/src/main/java/atlantafx/sampler/Launcher.java +++ b/sampler/src/main/java/atlantafx/sampler/Launcher.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler; import static java.nio.charset.StandardCharsets.UTF_8; @@ -32,11 +33,11 @@ import javafx.stage.Stage; public class Launcher extends Application { public static final boolean IS_DEV_MODE = "DEV".equalsIgnoreCase( - Resources.getPropertyOrEnv("atlantafx.mode", "ATLANTAFX_MODE") + Resources.getPropertyOrEnv("atlantafx.mode", "ATLANTAFX_MODE") ); public static final List SUPPORTED_HOTKEYS = List.of( - new KeyCodeCombination(KeyCode.F, KeyCombination.CONTROL_DOWN) + new KeyCodeCombination(KeyCode.F, KeyCombination.CONTROL_DOWN) ); public static void main(String[] args) { @@ -91,11 +92,12 @@ public class Launcher extends Application { private void loadApplicationProperties() { Properties properties = new Properties(); - try (InputStreamReader in = new InputStreamReader(Resources.getResourceAsStream("application.properties"), UTF_8)) { + try (InputStreamReader in = new InputStreamReader(Resources.getResourceAsStream("application.properties"), + UTF_8)) { properties.load(in); properties.forEach((key, value) -> System.setProperty( - String.valueOf(key), - String.valueOf(value) + String.valueOf(key), + String.valueOf(value) )); } catch (IOException e) { throw new RuntimeException(e); diff --git a/sampler/src/main/java/atlantafx/sampler/Resources.java b/sampler/src/main/java/atlantafx/sampler/Resources.java index 3d08269..16f0ee0 100755 --- a/sampler/src/main/java/atlantafx/sampler/Resources.java +++ b/sampler/src/main/java/atlantafx/sampler/Resources.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler; import java.io.InputStream; @@ -14,8 +15,8 @@ public final class Resources { public static InputStream getResourceAsStream(String resource) { String path = resolve(resource); return Objects.requireNonNull( - Launcher.class.getResourceAsStream(resolve(path)), - "Resource not found: " + path + Launcher.class.getResourceAsStream(resolve(path)), + "Resource not found: " + path ); } diff --git a/sampler/src/main/java/atlantafx/sampler/event/BrowseEvent.java b/sampler/src/main/java/atlantafx/sampler/event/BrowseEvent.java index 3dec733..8a30809 100644 --- a/sampler/src/main/java/atlantafx/sampler/event/BrowseEvent.java +++ b/sampler/src/main/java/atlantafx/sampler/event/BrowseEvent.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.event; import java.net.URI; @@ -18,7 +19,7 @@ public class BrowseEvent extends Event { @Override public String toString() { return "BrowseEvent{" + - "uri=" + uri + - "} " + super.toString(); + "uri=" + uri + + "} " + super.toString(); } } diff --git a/sampler/src/main/java/atlantafx/sampler/event/DefaultEventBus.java b/sampler/src/main/java/atlantafx/sampler/event/DefaultEventBus.java index b9454b5..1afa745 100644 --- a/sampler/src/main/java/atlantafx/sampler/event/DefaultEventBus.java +++ b/sampler/src/main/java/atlantafx/sampler/event/DefaultEventBus.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.event; import java.util.Map; @@ -20,7 +21,8 @@ import java.util.function.Consumer; @SuppressWarnings({"unchecked", "rawtypes"}) public final class DefaultEventBus implements EventBus { - public DefaultEventBus() {} + public DefaultEventBus() { + } private final Map, Set> subscribers = new ConcurrentHashMap<>(); @@ -55,9 +57,9 @@ public final class DefaultEventBus implements EventBus { Objects.requireNonNull(subscriber); subscribers.keySet().stream() - .filter(eventType::isAssignableFrom) - .map(subscribers::get) - .forEach(eventSubscribers -> eventSubscribers.remove(subscriber)); + .filter(eventType::isAssignableFrom) + .map(subscribers::get) + .forEach(eventSubscribers -> eventSubscribers.remove(subscriber)); } @Override @@ -66,9 +68,9 @@ public final class DefaultEventBus implements EventBus { Class eventType = event.getClass(); subscribers.keySet().stream() - .filter(type -> type.isAssignableFrom(eventType)) - .flatMap(type -> subscribers.get(type).stream()) - .forEach(subscriber -> publish(event, subscriber)); + .filter(type -> type.isAssignableFrom(eventType)) + .flatMap(type -> subscribers.get(type).stream()) + .forEach(subscriber -> publish(event, subscriber)); } private void publish(E event, Consumer subscriber) { diff --git a/sampler/src/main/java/atlantafx/sampler/event/Event.java b/sampler/src/main/java/atlantafx/sampler/event/Event.java index 0c35db8..b85f7d8 100644 --- a/sampler/src/main/java/atlantafx/sampler/event/Event.java +++ b/sampler/src/main/java/atlantafx/sampler/event/Event.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.event; import java.util.UUID; @@ -7,7 +8,8 @@ public abstract class Event { protected final UUID id = UUID.randomUUID(); - protected Event() { } + protected Event() { + } public UUID getId() { return id; @@ -15,8 +17,12 @@ public abstract class Event { @Override public boolean equals(Object o) { - if (this == o) { return true; } - if (!(o instanceof Event event)) { return false; } + if (this == o) { + return true; + } + if (!(o instanceof Event event)) { + return false; + } return id.equals(event.id); } @@ -28,7 +34,7 @@ public abstract class Event { @Override public String toString() { return "Event{" + - "id=" + id + - '}'; + "id=" + id + + '}'; } } diff --git a/sampler/src/main/java/atlantafx/sampler/event/EventBus.java b/sampler/src/main/java/atlantafx/sampler/event/EventBus.java index 71f6186..bc3063c 100644 --- a/sampler/src/main/java/atlantafx/sampler/event/EventBus.java +++ b/sampler/src/main/java/atlantafx/sampler/event/EventBus.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.event; import java.util.function.Consumer; @@ -8,9 +9,9 @@ public interface EventBus { /** * Subscribe to an event type * - * @param eventType the event type, can be a super class of all events to subscribe. + * @param eventType the event type, can be a super class of all events to subscribe. * @param subscriber the subscriber which will consume the events. - * @param the event type class. + * @param the event type class. */ void subscribe(Class eventType, Consumer subscriber); @@ -24,9 +25,9 @@ public interface EventBus { /** * Unsubscribe from an event type. * - * @param eventType the event type, can be a super class of all events to unsubscribe. + * @param eventType the event type, can be a super class of all events to unsubscribe. * @param subscriber the subscriber to unsubscribe. - * @param the event type class. + * @param the event type class. */ void unsubscribe(Class eventType, Consumer subscriber); diff --git a/sampler/src/main/java/atlantafx/sampler/event/HotkeyEvent.java b/sampler/src/main/java/atlantafx/sampler/event/HotkeyEvent.java index 25e6088..3baf1fb 100644 --- a/sampler/src/main/java/atlantafx/sampler/event/HotkeyEvent.java +++ b/sampler/src/main/java/atlantafx/sampler/event/HotkeyEvent.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.event; import javafx.scene.input.KeyCodeCombination; @@ -18,7 +19,7 @@ public class HotkeyEvent extends Event { @Override public String toString() { return "HotkeyEvent{" + - "keys=" + keys + - "} " + super.toString(); + "keys=" + keys + + "} " + super.toString(); } } diff --git a/sampler/src/main/java/atlantafx/sampler/event/Listener.java b/sampler/src/main/java/atlantafx/sampler/event/Listener.java index ef5336b..f0bfcab 100644 --- a/sampler/src/main/java/atlantafx/sampler/event/Listener.java +++ b/sampler/src/main/java/atlantafx/sampler/event/Listener.java @@ -1,8 +1,10 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.event; import java.lang.annotation.ElementType; import java.lang.annotation.Target; @Target(ElementType.METHOD) -public @interface Listener {} \ No newline at end of file +public @interface Listener { +} \ No newline at end of file diff --git a/sampler/src/main/java/atlantafx/sampler/event/ThemeEvent.java b/sampler/src/main/java/atlantafx/sampler/event/ThemeEvent.java index 8e928af..460d30f 100644 --- a/sampler/src/main/java/atlantafx/sampler/event/ThemeEvent.java +++ b/sampler/src/main/java/atlantafx/sampler/event/ThemeEvent.java @@ -27,7 +27,7 @@ public class ThemeEvent extends Event { @Override public String toString() { return "ThemeEvent{" + - "eventType=" + eventType + - "} " + super.toString(); + "eventType=" + eventType + + "} " + super.toString(); } } diff --git a/sampler/src/main/java/atlantafx/sampler/fake/SampleMenuBar.java b/sampler/src/main/java/atlantafx/sampler/fake/SampleMenuBar.java index 5d77da4..ff9f360 100644 --- a/sampler/src/main/java/atlantafx/sampler/fake/SampleMenuBar.java +++ b/sampler/src/main/java/atlantafx/sampler/fake/SampleMenuBar.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.fake; import static atlantafx.sampler.util.Controls.menuItem; @@ -27,11 +28,11 @@ public class SampleMenuBar extends MenuBar { public SampleMenuBar(Faker faker) { getMenus().addAll( - fileMenu(faker), - editMenu(), - viewMenu(), - toolsMenu(), - aboutMenu() + fileMenu(faker), + editMenu(), + viewMenu(), + toolsMenu(), + aboutMenu() ); } @@ -48,19 +49,19 @@ public class SampleMenuBar extends MenuBar { openRecentMenu.setMnemonicParsing(true); openRecentMenu.setOnAction(PRINT_SOURCE); openRecentMenu.getItems().addAll( - IntStream.range(0, 10).mapToObj(x -> new MenuItem(faker.file().fileName())).toList() + IntStream.range(0, 10).mapToObj(x -> new MenuItem(faker.file().fileName())).toList() ); fileMenu.getItems().addAll( - newMenu, - new SeparatorMenuItem(), - menuItem("Open", Feather.FOLDER, new KeyCodeCombination(KeyCode.O, CONTROL_DOWN)), - openRecentMenu, - new SeparatorMenuItem(), - menuItem("Save", Feather.SAVE, new KeyCodeCombination(KeyCode.S, CONTROL_DOWN)), - new MenuItem("Save As"), - new SeparatorMenuItem(), - new MenuItem("Exit") + newMenu, + new SeparatorMenuItem(), + menuItem("Open", Feather.FOLDER, new KeyCodeCombination(KeyCode.O, CONTROL_DOWN)), + openRecentMenu, + new SeparatorMenuItem(), + menuItem("Save", Feather.SAVE, new KeyCodeCombination(KeyCode.S, CONTROL_DOWN)), + new MenuItem("Save As"), + new SeparatorMenuItem(), + new MenuItem("Exit") ); return fileMenu; } @@ -71,12 +72,12 @@ public class SampleMenuBar extends MenuBar { editMenu.setOnAction(PRINT_SOURCE); editMenu.getItems().addAll( - menuItem("Undo", Feather.CORNER_DOWN_LEFT, new KeyCodeCombination(KeyCode.Z, CONTROL_DOWN)), - menuItem("Redo", Feather.CORNER_DOWN_RIGHT, new KeyCodeCombination(KeyCode.Y, CONTROL_DOWN)), - new SeparatorMenuItem(), - menuItem("Cut", Feather.SCISSORS, new KeyCodeCombination(KeyCode.X, CONTROL_DOWN)), - menuItem("Copy", Feather.COPY, new KeyCodeCombination(KeyCode.C, CONTROL_DOWN), true), - menuItem("Paste", Feather.CORNER_DOWN_LEFT, new KeyCodeCombination(KeyCode.V, CONTROL_DOWN)) + menuItem("Undo", Feather.CORNER_DOWN_LEFT, new KeyCodeCombination(KeyCode.Z, CONTROL_DOWN)), + menuItem("Redo", Feather.CORNER_DOWN_RIGHT, new KeyCodeCombination(KeyCode.Y, CONTROL_DOWN)), + new SeparatorMenuItem(), + menuItem("Cut", Feather.SCISSORS, new KeyCodeCombination(KeyCode.X, CONTROL_DOWN)), + menuItem("Copy", Feather.COPY, new KeyCodeCombination(KeyCode.C, CONTROL_DOWN), true), + menuItem("Paste", Feather.CORNER_DOWN_LEFT, new KeyCodeCombination(KeyCode.V, CONTROL_DOWN)) ); return editMenu; } @@ -105,12 +106,12 @@ public class SampleMenuBar extends MenuBar { toggleItem3.setToggleGroup(viewToggleGroup); viewMenu.getItems().addAll( - showToolbarItem, - showGridItem, - new SeparatorMenuItem(), - toggleItem1, - toggleItem2, - toggleItem3 + showToolbarItem, + showGridItem, + new SeparatorMenuItem(), + toggleItem1, + toggleItem2, + toggleItem3 ); return viewMenu; } @@ -129,21 +130,21 @@ public class SampleMenuBar extends MenuBar { aboutMenu.setOnAction(PRINT_SOURCE); var deeplyNestedMenu = new Menu("Very...", null, - new Menu("Very...", null, - new Menu("Deeply", null, - new Menu("Nested", null, - new MenuItem("Menu") - )))); + new Menu("Very...", null, + new Menu("Deeply", null, + new Menu("Nested", null, + new MenuItem("Menu") + )))); // NOTE: this won't be displayed because right container is reserved for submenu indication deeplyNestedMenu.setAccelerator(new KeyCodeCombination( - KeyCode.DIGIT1, SHIFT_DOWN, CONTROL_DOWN) + KeyCode.DIGIT1, SHIFT_DOWN, CONTROL_DOWN) ); aboutMenu.getItems().addAll( - new MenuItem("Help"), - new MenuItem("About"), - new SeparatorMenuItem(), - deeplyNestedMenu + new MenuItem("Help"), + new MenuItem("About"), + new SeparatorMenuItem(), + deeplyNestedMenu ); return aboutMenu; } diff --git a/sampler/src/main/java/atlantafx/sampler/fake/domain/Book.java b/sampler/src/main/java/atlantafx/sampler/fake/domain/Book.java index 28b11f5..35082b4 100644 --- a/sampler/src/main/java/atlantafx/sampler/fake/domain/Book.java +++ b/sampler/src/main/java/atlantafx/sampler/fake/domain/Book.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.fake.domain; import java.util.Objects; @@ -28,35 +29,57 @@ public final class Book { this.isbn = isbn; } - public UUID getId() { return id; } + public UUID getId() { + return id; + } - public void setId(UUID id) { this.id = id; } + public void setId(UUID id) { + this.id = id; + } - public boolean getState() { return state.get(); } + public boolean getState() { + return state.get(); + } - public void setState(boolean state) { this.state.set(state); } + public void setState(boolean state) { + this.state.set(state); + } - public BooleanProperty stateProperty() { return state; } + public BooleanProperty stateProperty() { + return state; + } - public String getAuthor() { return author; } + public String getAuthor() { + return author; + } - public void setAuthor(String author) { this.author = author; } + public void setAuthor(String author) { + this.author = author; + } - public String getTitle() { return title; } + public String getTitle() { + return title; + } - public void setTitle(String title) { this.title = title; } + public void setTitle(String title) { + this.title = title; + } - public String getIsbn() { return isbn; } + public String getIsbn() { + return isbn; + } - public void setIsbn(String isbn) { this.isbn = isbn; } + public void setIsbn(String isbn) { + this.isbn = isbn; + } public static Book random(Faker faker) { return new Book( - UUID.randomUUID(), - new SimpleBooleanProperty(), - faker.book().author(), - faker.book().title(), - faker.code().isbn10() + UUID.randomUUID(), + new SimpleBooleanProperty(), + faker.book().author(), + faker.book().title(), + faker.code().isbn10() ); } diff --git a/sampler/src/main/java/atlantafx/sampler/fake/domain/Product.java b/sampler/src/main/java/atlantafx/sampler/fake/domain/Product.java index d7f02ee..e820391 100644 --- a/sampler/src/main/java/atlantafx/sampler/fake/domain/Product.java +++ b/sampler/src/main/java/atlantafx/sampler/fake/domain/Product.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.fake.domain; import java.util.Objects; @@ -33,31 +34,57 @@ public final class Product { this.count = count; } - public int getId() { return id; } + public int getId() { + return id; + } - public void setId(int id) { this.id = id; } + public void setId(int id) { + this.id = id; + } - public boolean getState() { return state.get(); } + public boolean getState() { + return state.get(); + } - public BooleanProperty stateProperty() { return state; } + public BooleanProperty stateProperty() { + return state; + } - public void setState(boolean state) { this.state.set(state); } + public void setState(boolean state) { + this.state.set(state); + } - public String getBrand() { return brand; } + public String getBrand() { + return brand; + } - public void setBrand(String brand) { this.brand = brand; } + public void setBrand(String brand) { + this.brand = brand; + } - public String getName() { return name; } + public String getName() { + return name; + } - public void setName(String name) { this.name = name; } + public void setName(String name) { + this.name = name; + } - public String getPrice() { return price; } + public String getPrice() { + return price; + } - public void setPrice(String price) { this.price = price; } + public void setPrice(String price) { + this.price = price; + } - public Integer getCount() { return count; } + public Integer getCount() { + return count; + } - public void setCount(Integer count) { this.count = count; } + public void setCount(Integer count) { + this.count = count; + } public double getAvailability() { return count * 1.0 / MAX_STOCK_SIZE; @@ -65,12 +92,12 @@ public final class Product { public static Product random(int id, Faker faker) { return new Product( - id, - new SimpleBooleanProperty(), - faker.commerce().brand(), - faker.commerce().productName(), - faker.commerce().price(), - faker.random().nextInt(0, MAX_STOCK_SIZE) + id, + new SimpleBooleanProperty(), + faker.commerce().brand(), + faker.commerce().productName(), + faker.commerce().price(), + faker.random().nextInt(0, MAX_STOCK_SIZE) ); } diff --git a/sampler/src/main/java/atlantafx/sampler/layout/ApplicationWindow.java b/sampler/src/main/java/atlantafx/sampler/layout/ApplicationWindow.java index a9995c1..ccc687a 100755 --- a/sampler/src/main/java/atlantafx/sampler/layout/ApplicationWindow.java +++ b/sampler/src/main/java/atlantafx/sampler/layout/ApplicationWindow.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.layout; import atlantafx.sampler.util.Containers; @@ -14,8 +15,8 @@ public class ApplicationWindow extends AnchorPane { var body = new StackPane(); body.getStyleClass().add("body"); body.getChildren().setAll( - new Overlay(), - new MainLayer() + new Overlay(), + new MainLayer() ); Containers.setAnchors(body, Insets.EMPTY); diff --git a/sampler/src/main/java/atlantafx/sampler/layout/HeaderBar.java b/sampler/src/main/java/atlantafx/sampler/layout/HeaderBar.java index 6a3ad4d..2b03d8a 100644 --- a/sampler/src/main/java/atlantafx/sampler/layout/HeaderBar.java +++ b/sampler/src/main/java/atlantafx/sampler/layout/HeaderBar.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.layout; import static atlantafx.base.theme.Styles.TEXT_SMALL; @@ -97,16 +98,18 @@ class HeaderBar extends HBox { var quickConfigBtn = new FontIcon(Material2OutlinedMZ.STYLE); quickConfigBtn.mouseTransparentProperty().bind(model.themeChangeToggleProperty().not()); quickConfigBtn.opacityProperty().bind(Bindings.createDoubleBinding( - () -> model.themeChangeToggleProperty().get() ? 1.0 : 0.5, model.themeChangeToggleProperty() + () -> model.themeChangeToggleProperty().get() ? 1.0 : 0.5, model.themeChangeToggleProperty() )); quickConfigBtn.setOnMouseClicked(e -> { - if (quickConfigActionHandler != null) { quickConfigActionHandler.accept(popoverAnchor); } + if (quickConfigActionHandler != null) { + quickConfigActionHandler.accept(popoverAnchor); + } }); var sourceCodeBtn = new FontIcon(ICON_CODE); sourceCodeBtn.mouseTransparentProperty().bind(model.sourceCodeToggleProperty().not()); sourceCodeBtn.opacityProperty().bind(Bindings.createDoubleBinding( - () -> model.sourceCodeToggleProperty().get() ? 1.0 : 0.5, model.sourceCodeToggleProperty() + () -> model.sourceCodeToggleProperty().get() ? 1.0 : 0.5, model.sourceCodeToggleProperty() )); sourceCodeBtn.setOnMouseClicked(e -> model.nextSubLayer()); @@ -133,14 +136,14 @@ class HeaderBar extends HBox { setPrefHeight(HEADER_HEIGHT); setAlignment(Pos.CENTER_LEFT); getChildren().setAll( - logoBox, - titleLabel, - new Spacer(), - searchField, - popoverAnchor, - quickConfigBtn, - sourceCodeBtn, - githubLink + logoBox, + titleLabel, + new Spacer(), + searchField, + popoverAnchor, + quickConfigBtn, + sourceCodeBtn, + githubLink ); if (IS_DEV_MODE) { diff --git a/sampler/src/main/java/atlantafx/sampler/layout/MainLayer.java b/sampler/src/main/java/atlantafx/sampler/layout/MainLayer.java index 2e6f742..fb1268c 100644 --- a/sampler/src/main/java/atlantafx/sampler/layout/MainLayer.java +++ b/sampler/src/main/java/atlantafx/sampler/layout/MainLayer.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.layout; import static atlantafx.base.controls.Popover.ArrowLocation.TOP_CENTER; @@ -73,7 +74,9 @@ class MainLayer extends BorderPane { headerBar.setQuickConfigActionHandler(this::showThemeConfigPopover); model.selectedPageProperty().addListener((obs, old, val) -> { - if (val != null) { loadPage(val); } + if (val != null) { + loadPage(val); + } }); model.currentSubLayerProperty().addListener((obs, old, val) -> { @@ -85,7 +88,8 @@ class MainLayer extends BorderPane { // update code view color theme on app theme change DefaultEventBus.getInstance().subscribe(ThemeEvent.class, e -> { - if (ThemeManager.getInstance().getTheme() != null && model.currentSubLayerProperty().get() == SubLayer.SOURCE_CODE) { + if (ThemeManager.getInstance().getTheme() != null && + model.currentSubLayerProperty().get() == SubLayer.SOURCE_CODE) { showSourceCode(); } }); @@ -94,15 +98,15 @@ class MainLayer extends BorderPane { private void loadPage(Class pageClass) { try { final Page prevPage = (Page) subLayerPane.getChildren().stream() - .filter(c -> c instanceof Page) - .findFirst() - .orElse(null); + .filter(c -> c instanceof Page) + .findFirst() + .orElse(null); final Page nextPage = pageClass.getDeclaredConstructor().newInstance(); model.setPageData( - nextPage.getName(), - nextPage.canChangeThemeSettings(), - nextPage.canDisplaySourceCode() + nextPage.getName(), + nextPage.canChangeThemeSettings(), + nextPage.canDisplaySourceCode() ); // startup, no prev page, no animation @@ -123,7 +127,9 @@ class MainLayer extends BorderPane { transition.setFromValue(0.0); transition.setToValue(1.0); transition.setOnFinished(t -> { - if (nextPage instanceof Pane nextPane) { nextPane.toFront(); } + if (nextPage instanceof Pane nextPane) { + nextPane.toFront(); + } }); transition.play(); } catch (Exception e) { diff --git a/sampler/src/main/java/atlantafx/sampler/layout/MainModel.java b/sampler/src/main/java/atlantafx/sampler/layout/MainModel.java index 1ebed79..db7754e 100644 --- a/sampler/src/main/java/atlantafx/sampler/layout/MainModel.java +++ b/sampler/src/main/java/atlantafx/sampler/layout/MainModel.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.layout; import static atlantafx.sampler.layout.MainModel.SubLayer.PAGE; diff --git a/sampler/src/main/java/atlantafx/sampler/layout/Overlay.java b/sampler/src/main/java/atlantafx/sampler/layout/Overlay.java index 27d587e..665274a 100644 --- a/sampler/src/main/java/atlantafx/sampler/layout/Overlay.java +++ b/sampler/src/main/java/atlantafx/sampler/layout/Overlay.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.layout; import atlantafx.sampler.util.Animations; @@ -51,8 +52,8 @@ public class Overlay extends StackPane { scrollPane = new ScrollPane(); Containers.setScrollConstraints(scrollPane, - ScrollPane.ScrollBarPolicy.AS_NEEDED, true, - ScrollPane.ScrollBarPolicy.NEVER, true + ScrollPane.ScrollBarPolicy.AS_NEEDED, true, + ScrollPane.ScrollBarPolicy.NEVER, true ); scrollPane.setMaxHeight(10_000); // scroll pane won't work without height specified @@ -67,14 +68,17 @@ public class Overlay extends StackPane { // hide overlay by pressing ESC (only works when overlay or one of its children has focus, // that's why we requesting it in the toFront()) addEventHandler(KeyEvent.KEY_PRESSED, e -> { - if (e.getCode() == KeyCode.ESCAPE) { hideAndConsume.accept(e); } + if (e.getCode() == KeyCode.ESCAPE) { + hideAndConsume.accept(e); + } }); // hide overlay by clicking outside content area setOnMouseClicked(e -> { Pane content = getContent(); Node eventSource = e.getPickResult().getIntersectedNode(); - if (e.getButton() == MouseButton.PRIMARY && content != null && !NodeUtils.isDescendant(content, eventSource)) { + if (e.getButton() == MouseButton.PRIMARY && content != null && + !NodeUtils.isDescendant(content, eventSource)) { hideAndConsume.accept(e); } }); @@ -125,13 +129,15 @@ public class Overlay extends StackPane { public boolean contains(Pane content) { return content != null && - getContentWrapper().getChildren().size() > 0 && - getContentWrapper().getChildren().get(0).equals(content); + getContentWrapper().getChildren().size() > 0 && + getContentWrapper().getChildren().get(0).equals(content); } @Override public void toFront() { - if (onFrontProperty.get()) { return; } + if (onFrontProperty.get()) { + return; + } super.toFront(); fadeInTransition.playFromStart(); onFrontProperty.set(true); @@ -139,7 +145,9 @@ public class Overlay extends StackPane { @Override public void toBack() { - if (!onFrontProperty.get()) { return; } + if (!onFrontProperty.get()) { + return; + } super.toBack(); fadeOutTransition.playFromStart(); onFrontProperty.set(false); diff --git a/sampler/src/main/java/atlantafx/sampler/layout/Sidebar.java b/sampler/src/main/java/atlantafx/sampler/layout/Sidebar.java index 2ec6601..2d9fc2c 100644 --- a/sampler/src/main/java/atlantafx/sampler/layout/Sidebar.java +++ b/sampler/src/main/java/atlantafx/sampler/layout/Sidebar.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.layout; import static javafx.scene.control.ScrollPane.ScrollBarPolicy.AS_NEEDED; @@ -180,17 +181,23 @@ class Sidebar extends StackPane { } public Optional findLink(Class pageClass) { - if (pageClass == null) { return Optional.empty(); } + if (pageClass == null) { + return Optional.empty(); + } return Optional.ofNullable(registry.get(pageClass)); } public Optional getPrevious() { var current = content.indexOf(registry.get(model.selectedPageProperty().get())); - if (!(current > 0)) { return Optional.empty(); } + if (!(current > 0)) { + return Optional.empty(); + } for (int i = current - 1; i >= 0; i--) { var r = content.get(i); - if (r instanceof NavLink link) { return Optional.of(link); } + if (r instanceof NavLink link) { + return Optional.of(link); + } } return Optional.empty(); @@ -198,11 +205,15 @@ class Sidebar extends StackPane { public Optional getNext() { var current = content.indexOf(registry.get(model.selectedPageProperty().get())); - if (!(current >= 0 && current < content.size() - 1)) { return Optional.empty(); } // has next + if (!(current >= 0 && current < content.size() - 1)) { + return Optional.empty(); + } // has next for (int i = current + 1; i < content.size(); i++) { var r = content.get(i); - if (r instanceof NavLink link) { return Optional.of(link); } + if (r instanceof NavLink link) { + return Optional.of(link); + } } return Optional.empty(); @@ -210,56 +221,56 @@ class Sidebar extends StackPane { private ObservableList create() { return FXCollections.observableArrayList( - caption("GENERAL"), - navLink(ThemePage.NAME, ThemePage.class), - navLink(TypographyPage.NAME, TypographyPage.class), - navLink(IconsPage.NAME, IconsPage.class), - caption("COMPONENTS"), - navLink(OverviewPage.NAME, OverviewPage.class), - navLink(InputGroupPage.NAME, InputGroupPage.class), - new Spacer(10, Orientation.VERTICAL), - navLink(AccordionPage.NAME, AccordionPage.class), - navLink(BreadcrumbsPage.NAME, BreadcrumbsPage.class), - navLink(ButtonPage.NAME, ButtonPage.class), - navLink(ChartPage.NAME, ChartPage.class), - navLink(CheckBoxPage.NAME, CheckBoxPage.class), - navLink(ColorPickerPage.NAME, ColorPickerPage.class), - navLink(ComboBoxPage.NAME, ComboBoxPage.class, "ChoiceBox"), - navLink(CustomTextFieldPage.NAME, CustomTextFieldPage.class), - navLink(DatePickerPage.NAME, DatePickerPage.class), - navLink(DialogPage.NAME, DialogPage.class), - navLink(HTMLEditorPage.NAME, HTMLEditorPage.class), - navLink(LabelPage.NAME, LabelPage.class), - navLink(ListPage.NAME, ListPage.class), - navLink(MenuPage.NAME, MenuPage.class), - navLink(MenuButtonPage.NAME, MenuButtonPage.class, "SplitMenuButton"), - navLink(PaginationPage.NAME, PaginationPage.class), - navLink(PopoverPage.NAME, PopoverPage.class), - navLink(ProgressPage.NAME, ProgressPage.class), - navLink(RadioButtonPage.NAME, RadioButtonPage.class), - navLink(ScrollPanePage.NAME, ScrollPanePage.class), - navLink(SeparatorPage.NAME, SeparatorPage.class), - navLink(SliderPage.NAME, SliderPage.class), - navLink(SpinnerPage.NAME, SpinnerPage.class), - navLink(SplitPanePage.NAME, SplitPanePage.class), - navLink(TablePage.NAME, TablePage.class), - navLink(TabPanePage.NAME, TabPanePage.class), - navLink(TextAreaPage.NAME, TextAreaPage.class), - navLink(TextFieldPage.NAME, TextFieldPage.class, "PasswordField"), - navLink(TitledPanePage.NAME, TitledPanePage.class), - navLink(ToggleButtonPage.NAME, ToggleButtonPage.class), - navLink(ToggleSwitchPage.NAME, ToggleSwitchPage.class), - navLink(ToolBarPage.NAME, ToolBarPage.class), - navLink(TooltipPage.NAME, TooltipPage.class), - navLink(TreePage.NAME, TreePage.class), - navLink(TreeTablePage.NAME, TreeTablePage.class), - caption("SHOWCASE"), - navLink(FileManagerPage.NAME, FileManagerPage.class), - navLink(MusicPlayerPage.NAME, MusicPlayerPage.class), - navLink(WidgetCollectionPage.NAME, - WidgetCollectionPage.class, - "Card", "Message", "Stepper", "Tag" - ) + caption("GENERAL"), + navLink(ThemePage.NAME, ThemePage.class), + navLink(TypographyPage.NAME, TypographyPage.class), + navLink(IconsPage.NAME, IconsPage.class), + caption("COMPONENTS"), + navLink(OverviewPage.NAME, OverviewPage.class), + navLink(InputGroupPage.NAME, InputGroupPage.class), + new Spacer(10, Orientation.VERTICAL), + navLink(AccordionPage.NAME, AccordionPage.class), + navLink(BreadcrumbsPage.NAME, BreadcrumbsPage.class), + navLink(ButtonPage.NAME, ButtonPage.class), + navLink(ChartPage.NAME, ChartPage.class), + navLink(CheckBoxPage.NAME, CheckBoxPage.class), + navLink(ColorPickerPage.NAME, ColorPickerPage.class), + navLink(ComboBoxPage.NAME, ComboBoxPage.class, "ChoiceBox"), + navLink(CustomTextFieldPage.NAME, CustomTextFieldPage.class), + navLink(DatePickerPage.NAME, DatePickerPage.class), + navLink(DialogPage.NAME, DialogPage.class), + navLink(HTMLEditorPage.NAME, HTMLEditorPage.class), + navLink(LabelPage.NAME, LabelPage.class), + navLink(ListPage.NAME, ListPage.class), + navLink(MenuPage.NAME, MenuPage.class), + navLink(MenuButtonPage.NAME, MenuButtonPage.class, "SplitMenuButton"), + navLink(PaginationPage.NAME, PaginationPage.class), + navLink(PopoverPage.NAME, PopoverPage.class), + navLink(ProgressPage.NAME, ProgressPage.class), + navLink(RadioButtonPage.NAME, RadioButtonPage.class), + navLink(ScrollPanePage.NAME, ScrollPanePage.class), + navLink(SeparatorPage.NAME, SeparatorPage.class), + navLink(SliderPage.NAME, SliderPage.class), + navLink(SpinnerPage.NAME, SpinnerPage.class), + navLink(SplitPanePage.NAME, SplitPanePage.class), + navLink(TablePage.NAME, TablePage.class), + navLink(TabPanePage.NAME, TabPanePage.class), + navLink(TextAreaPage.NAME, TextAreaPage.class), + navLink(TextFieldPage.NAME, TextFieldPage.class, "PasswordField"), + navLink(TitledPanePage.NAME, TitledPanePage.class), + navLink(ToggleButtonPage.NAME, ToggleButtonPage.class), + navLink(ToggleSwitchPage.NAME, ToggleSwitchPage.class), + navLink(ToolBarPage.NAME, ToolBarPage.class), + navLink(TooltipPage.NAME, TooltipPage.class), + navLink(TreePage.NAME, TreePage.class), + navLink(TreeTablePage.NAME, TreeTablePage.class), + caption("SHOWCASE"), + navLink(FileManagerPage.NAME, FileManagerPage.class), + navLink(MusicPlayerPage.NAME, MusicPlayerPage.class), + navLink(WidgetCollectionPage.NAME, + WidgetCollectionPage.class, + "Card", "Message", "Stepper", "Tag" + ) ); } @@ -310,7 +321,8 @@ class Sidebar extends StackPane { public boolean matches(String filter) { Objects.requireNonNull(filter); - return contains(getText(), filter) || searchKeywords.stream().anyMatch(keyword -> contains(keyword, filter)); + return contains(getText(), filter) || + searchKeywords.stream().anyMatch(keyword -> contains(keyword, filter)); } private boolean contains(String text, String filter) { diff --git a/sampler/src/main/java/atlantafx/sampler/page/AbstractPage.java b/sampler/src/main/java/atlantafx/sampler/page/AbstractPage.java index d6ed988..05b456e 100755 --- a/sampler/src/main/java/atlantafx/sampler/page/AbstractPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/AbstractPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page; import static atlantafx.sampler.util.Containers.setScrollConstraints; @@ -66,12 +67,15 @@ public abstract class AbstractPage extends BorderPane implements Page { } @Override - public void reset() { } + public void reset() { + } @Override protected void layoutChildren() { super.layoutChildren(); - if (isRendered) { return; } + if (isRendered) { + return; + } isRendered = true; onRendered(); diff --git a/sampler/src/main/java/atlantafx/sampler/page/CodeViewer.java b/sampler/src/main/java/atlantafx/sampler/page/CodeViewer.java index 1620736..6e334a1 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/CodeViewer.java +++ b/sampler/src/main/java/atlantafx/sampler/page/CodeViewer.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page; import static java.nio.charset.StandardCharsets.UTF_8; @@ -43,24 +44,24 @@ public class CodeViewer extends AnchorPane { var hljsLineNum = Resources.getResourceAsStream(HLJS_LN_LIB)) { var content = new StringBuilder() - .append("") // mandatory for line numbers plugin - .append("") - .append("") - .append("") - .append("") - .append("") - .append("") - .append("") - .append("") - .append("") - .append("
")
-                    .append("")
-                    .append(new String(source.readAllBytes(), UTF_8))
-                    .append("")
-                    .append("
") - .append("") - .append("") - .toString(); + .append("") // mandatory for line numbers plugin + .append("") + .append("") + .append("") + .append("") + .append("") + .append("") + .append("") + .append("") + .append("") + .append("
")
+                .append("")
+                .append(new String(source.readAllBytes(), UTF_8))
+                .append("")
+                .append("
") + .append("") + .append("") + .toString(); webView.setPageFill(Color.TRANSPARENT); webView.getEngine().loadContent(content); diff --git a/sampler/src/main/java/atlantafx/sampler/page/OverlayDialog.java b/sampler/src/main/java/atlantafx/sampler/page/OverlayDialog.java index 2f55930..1ceaa8b 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/OverlayDialog.java +++ b/sampler/src/main/java/atlantafx/sampler/page/OverlayDialog.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page; import static atlantafx.base.theme.Styles.BUTTON_CIRCLE; @@ -48,9 +49,9 @@ public abstract class OverlayDialog extends VBox { headerBox.getStyleClass().add("header"); headerBox.setAlignment(Pos.CENTER_LEFT); headerBox.getChildren().setAll( - titleLabel, - new Spacer(), - topCloseBtn + titleLabel, + new Spacer(), + topCloseBtn ); VBox.setVgrow(headerBox, Priority.NEVER); @@ -63,8 +64,8 @@ public abstract class OverlayDialog extends VBox { footerBox.getStyleClass().add("footer"); footerBox.setAlignment(Pos.CENTER_RIGHT); footerBox.getChildren().setAll( - new Spacer(), - bottomCloseBtn + new Spacer(), + bottomCloseBtn ); VBox.setVgrow(footerBox, Priority.NEVER); @@ -91,7 +92,7 @@ public abstract class OverlayDialog extends VBox { getChildren().set(CONTENT_CHILD_INDEX, content); } else { throw new UnsupportedOperationException("Content cannot be placed because of unexpected children size. " + - "You should override 'OverlayDialog#setContent()' and place it manually."); + "You should override 'OverlayDialog#setContent()' and place it manually."); } } diff --git a/sampler/src/main/java/atlantafx/sampler/page/Page.java b/sampler/src/main/java/atlantafx/sampler/page/Page.java index d0845c9..278eb0c 100755 --- a/sampler/src/main/java/atlantafx/sampler/page/Page.java +++ b/sampler/src/main/java/atlantafx/sampler/page/Page.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page; import javafx.scene.Parent; diff --git a/sampler/src/main/java/atlantafx/sampler/page/QuickConfigMenu.java b/sampler/src/main/java/atlantafx/sampler/page/QuickConfigMenu.java index 6b36a6d..28e3013 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/QuickConfigMenu.java +++ b/sampler/src/main/java/atlantafx/sampler/page/QuickConfigMenu.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page; import static atlantafx.base.theme.Styles.BUTTON_CIRCLE; @@ -80,12 +81,16 @@ public class QuickConfigMenu extends StackPane { } private MainMenu getOrCreateMainMenu() { - if (mainMenu == null) { mainMenu = new MainMenu(navHandler); } + if (mainMenu == null) { + mainMenu = new MainMenu(navHandler); + } return mainMenu; } private ThemeSelectionMenu getOrCreateThemeSelectionMenu() { - if (themeSelectionMenu == null) { themeSelectionMenu = new ThemeSelectionMenu(navHandler); } + if (themeSelectionMenu == null) { + themeSelectionMenu = new ThemeSelectionMenu(navHandler); + } return themeSelectionMenu; } @@ -124,10 +129,10 @@ public class QuickConfigMenu extends StackPane { private final IntegerProperty zoom = new SimpleIntegerProperty(DEFAULT_ZOOM); private final BooleanBinding canZoomIn = Bindings.createBooleanBinding( - () -> SUPPORTED_ZOOM.indexOf(zoom.get()) < SUPPORTED_ZOOM.size() - 1, zoom + () -> SUPPORTED_ZOOM.indexOf(zoom.get()) < SUPPORTED_ZOOM.size() - 1, zoom ); private final BooleanBinding canZoomOut = Bindings.createBooleanBinding( - () -> SUPPORTED_ZOOM.indexOf(zoom.get()) >= 1, zoom + () -> SUPPORTED_ZOOM.indexOf(zoom.get()) >= 1, zoom ); public MainMenu(Consumer navHandler) { @@ -178,11 +183,11 @@ public class QuickConfigMenu extends StackPane { // ~ getChildren().setAll( - themeSelectionMenu, - new Separator(), - accentSelector, - new Separator(), - zoomBox + themeSelectionMenu, + new Separator(), + accentSelector, + new Separator(), + zoomBox ); } @@ -234,8 +239,8 @@ public class QuickConfigMenu extends StackPane { @Override public void update() { items.forEach(item -> item.pseudoClassStateChanged( - SELECTED, - Objects.equals(item.getUserData(), ThemeManager.getInstance().getTheme().getName()) + SELECTED, + Objects.equals(item.getUserData(), ThemeManager.getInstance().getTheme().getName()) )); } diff --git a/sampler/src/main/java/atlantafx/sampler/page/SampleBlock.java b/sampler/src/main/java/atlantafx/sampler/page/SampleBlock.java index 4f6d72b..031c246 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/SampleBlock.java +++ b/sampler/src/main/java/atlantafx/sampler/page/SampleBlock.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page; import java.util.Objects; diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/AccordionPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/AccordionPage.java index 29aee26..20faf9d 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/AccordionPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/AccordionPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.base.theme.Styles.DENSE; @@ -31,7 +32,9 @@ public class AccordionPage extends AbstractPage { public static final String NAME = "Accordion"; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } private final BooleanProperty expandedProperty = new SimpleBooleanProperty(true); private final BooleanProperty animatedProperty = new SimpleBooleanProperty(true); @@ -43,8 +46,8 @@ public class AccordionPage extends AbstractPage { accordion = createPlayground(); var sample = new SampleBlock( - "Playground", - new VBox(SampleBlock.BLOCK_VGAP, createControls(), accordion) + "Playground", + new VBox(SampleBlock.BLOCK_VGAP, createControls(), accordion) ); sample.setFillHeight(true); setUserContent(sample); @@ -61,20 +64,20 @@ public class AccordionPage extends AbstractPage { var denseToggle = new ToggleSwitch("Dense"); denseToggle.selectedProperty().addListener( - (obs, old, val) -> accordion.getPanes().forEach(p -> toggleStyleClass(p, DENSE)) + (obs, old, val) -> accordion.getPanes().forEach(p -> toggleStyleClass(p, DENSE)) ); var altIconToggle = new ToggleSwitch("Alt icon"); altIconToggle.selectedProperty().addListener( - (obs, old, val) -> accordion.getPanes().forEach(p -> toggleStyleClass(p, Tweaks.ALT_ICON)) + (obs, old, val) -> accordion.getPanes().forEach(p -> toggleStyleClass(p, Tweaks.ALT_ICON)) ); var controls = new HBox( - BLOCK_HGAP, - animatedToggle, - expandedToggle, - denseToggle, - altIconToggle + BLOCK_HGAP, + animatedToggle, + expandedToggle, + denseToggle, + altIconToggle ); controls.setAlignment(Pos.CENTER); controls.setPadding(new Insets(0, 0, 0, 2)); @@ -101,8 +104,8 @@ public class AccordionPage extends AbstractPage { disabledBlock.setDisable(true); var imageBlock = new TitledPane("_Image", new VBox(10, - new ImageView(new Image(Resources.getResourceAsStream("images/20_min_adventure.jpg"))), - new TextFlow(new Text(FAKER.rickAndMorty().quote())) + new ImageView(new Image(Resources.getResourceAsStream("images/20_min_adventure.jpg"))), + new TextFlow(new Text(FAKER.rickAndMorty().quote())) )); imageBlock.animatedProperty().bind(animatedProperty); imageBlock.setMnemonicParsing(true); @@ -110,10 +113,10 @@ public class AccordionPage extends AbstractPage { // ~ var accordion = new Accordion( - textBlock, - scrollableTextBlock, - disabledBlock, - imageBlock + textBlock, + scrollableTextBlock, + disabledBlock, + imageBlock ); // prevents accordion from being completely collapsed diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/BreadcrumbsPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/BreadcrumbsPage.java index 7eb2813..0945b0d 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/BreadcrumbsPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/BreadcrumbsPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import atlantafx.base.controls.Breadcrumbs; @@ -25,15 +26,17 @@ public class BreadcrumbsPage extends AbstractPage { private static final int CRUMB_COUNT = 5; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public BreadcrumbsPage() { super(); setUserContent(new VBox( - Page.PAGE_VGAP, - basicSample(), - customCrumbSample(), - customDividerSample() + Page.PAGE_VGAP, + basicSample(), + customCrumbSample(), + customDividerSample() )); } @@ -54,7 +57,9 @@ public class BreadcrumbsPage extends AbstractPage { private SampleBlock customDividerSample() { Callback, ? extends Node> dividerFactory = item -> { - if (item == null) { return new Label("", new FontIcon(Material2AL.HOME)); } + if (item == null) { + return new Label("", new FontIcon(Material2AL.HOME)); + } return !item.isLast() ? new Label("", new FontIcon(Material2AL.CHEVRON_RIGHT)) : null; }; @@ -64,7 +69,7 @@ public class BreadcrumbsPage extends AbstractPage { private HBox createBreadcrumbs(Callback, ButtonBase> crumbFactory, Callback, ? extends Node> dividerFactory) { BreadCrumbItem model = Breadcrumbs.buildTreeModel( - generate(() -> FAKER.science().element(), CRUMB_COUNT).toArray(String[]::new) + generate(() -> FAKER.science().element(), CRUMB_COUNT).toArray(String[]::new) ); var nextBtn = new Button("Next"); @@ -72,8 +77,12 @@ public class BreadcrumbsPage extends AbstractPage { var breadcrumbs = new Breadcrumbs<>(model); breadcrumbs.setSelectedCrumb(getAncestor(model, CRUMB_COUNT / 2)); - if (crumbFactory != null) { breadcrumbs.setCrumbFactory(crumbFactory); } - if (dividerFactory != null) { breadcrumbs.setDividerFactory(dividerFactory); } + if (crumbFactory != null) { + breadcrumbs.setCrumbFactory(crumbFactory); + } + if (dividerFactory != null) { + breadcrumbs.setDividerFactory(dividerFactory); + } nextBtn.setOnAction(e -> { BreadCrumbItem selected = breadcrumbs.getSelectedCrumb(); diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/ButtonPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/ButtonPage.java index 813a01e..280c448 100755 --- a/sampler/src/main/java/atlantafx/sampler/page/components/ButtonPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/ButtonPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.base.theme.Styles.ACCENT; @@ -119,8 +120,8 @@ public class ButtonPage extends AbstractPage { flatDangerBtn.getStyleClass().addAll(BUTTON_ICON, FLAT, DANGER); var content = new HBox(BLOCK_HGAP, - basicBtn, accentBtn, successBtn, dangerBtn, - flatAccentBtn, flatSuccessBtn, flatDangerBtn + basicBtn, accentBtn, successBtn, dangerBtn, + flatAccentBtn, flatSuccessBtn, flatDangerBtn ); return new SampleBlock("Icon", content); } @@ -155,8 +156,8 @@ public class ButtonPage extends AbstractPage { flatDangerBtn.setShape(new Circle(50)); var content = new HBox(BLOCK_HGAP, - basicBtn, accentBtn, successBtn, dangerBtn, - flatAccentBtn, flatSuccessBtn, flatDangerBtn + basicBtn, accentBtn, successBtn, dangerBtn, + flatAccentBtn, flatSuccessBtn, flatDangerBtn ); return new SampleBlock("Circular", content); } @@ -215,22 +216,22 @@ public class ButtonPage extends AbstractPage { var btn = new Button("DO SOMETHING!"); btn.getStyleClass().addAll(SUCCESS, LARGE); btn.setStyle(""" - -color-button-bg: linear-gradient(to bottom right, -color-success-emphasis, darkblue); - -color-button-bg-hover: -color-button-bg; - -color-button-bg-focused: -color-button-bg; - -color-button-bg-pressed: -color-button-bg; - """); + -color-button-bg: linear-gradient(to bottom right, -color-success-emphasis, darkblue); + -color-button-bg-hover: -color-button-bg; + -color-button-bg-focused: -color-button-bg; + -color-button-bg-pressed: -color-button-bg; + """); var iconBtn = new Button("", new FontIcon(Material2AL.FAVORITE)); iconBtn.getStyleClass().addAll("favorite-button", BUTTON_CIRCLE, FLAT, DANGER); new CSSFragment(""" - .favorite-button.button >.ikonli-font-icon { - -fx-fill: linear-gradient(to bottom right, pink, -color-danger-emphasis); - -fx-icon-color: linear-gradient(to bottom right, pink, -color-danger-emphasis); - -fx-font-size: 32px; - -fx-icon-size: 32px; - } - """).addTo(iconBtn); + .favorite-button.button >.ikonli-font-icon { + -fx-fill: linear-gradient(to bottom right, pink, -color-danger-emphasis); + -fx-icon-color: linear-gradient(to bottom right, pink, -color-danger-emphasis); + -fx-font-size: 32px; + -fx-icon-size: 32px; + } + """).addTo(iconBtn); var content = new HBox(BLOCK_HGAP, btn, iconBtn); content.setAlignment(Pos.CENTER_LEFT); diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/ChartPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/ChartPage.java index e13f8c8..2cfa268 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/ChartPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/ChartPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import atlantafx.base.controls.Spacer; @@ -39,7 +40,9 @@ public class ChartPage extends AbstractPage { public static final String NAME = "Chart"; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } private final BorderPane chartWrapper = new BorderPane(); private final ComboBox exampleSelect = new ComboBox<>(); @@ -47,7 +50,7 @@ public class ChartPage extends AbstractPage { public ChartPage() { super(); setUserContent(new VBox( - new SampleBlock("Playground", createPlayground()) + new SampleBlock("Playground", createPlayground()) )); } @@ -55,7 +58,9 @@ public class ChartPage extends AbstractPage { exampleSelect.setMaxWidth(Double.MAX_VALUE); exampleSelect.getItems().setAll(Example.values()); exampleSelect.getSelectionModel().selectedItemProperty().addListener((obs, old, val) -> { - if (val == null) { return; } + if (val == null) { + return; + } Chart newChart = createChart(val); @@ -78,7 +83,9 @@ public class ChartPage extends AbstractPage { var disableToggle = new ToggleSwitch("Disable"); disableToggle.selectedProperty().addListener((obs, old, val) -> findDisplayedChart().ifPresent(ch -> { - if (val != null) { ch.setDisable(val); } + if (val != null) { + ch.setDisable(val); + } })); var controls = new HBox(disableToggle); @@ -86,9 +93,9 @@ public class ChartPage extends AbstractPage { VBox playground = new VBox(SampleBlock.BLOCK_VGAP); playground.getChildren().setAll( - new HBox(new Label("Select an example:"), new Spacer(), disableToggle), - exampleSelect, - chartWrapper + new HBox(new Label("Select an example:"), new Spacer(), disableToggle), + exampleSelect, + chartWrapper ); return playground; @@ -102,20 +109,36 @@ public class ChartPage extends AbstractPage { private Optional findDisplayedChart() { return chartWrapper.getChildren().size() > 0 ? - Optional.of((Chart) chartWrapper.getChildren().get(0)) : - Optional.empty(); + Optional.of((Chart) chartWrapper.getChildren().get(0)) : + Optional.empty(); } private Chart createChart(Example example) { switch (example) { - case AREA_CHART -> { return areaChart(false); } - case BAR_CHART -> { return barChart(false); } - case BUBBLE_CHART -> { return bubbleChart(); } - case LINE_CHART -> { return lineChart(); } - case PIE_CHART -> { return pieChart(); } - case SCATTER_CHART -> { return scatterChart(); } - case STACKED_AREA_CHART -> { return areaChart(true); } - case STACKED_BAR_CHART -> { return barChart(true); } + case AREA_CHART -> { + return areaChart(false); + } + case BAR_CHART -> { + return barChart(false); + } + case BUBBLE_CHART -> { + return bubbleChart(); + } + case LINE_CHART -> { + return lineChart(); + } + case PIE_CHART -> { + return pieChart(); + } + case SCATTER_CHART -> { + return scatterChart(); + } + case STACKED_AREA_CHART -> { + return areaChart(true); + } + case STACKED_BAR_CHART -> { + return barChart(true); + } default -> throw new IllegalArgumentException("Unexpected enum value: " + example); } } @@ -131,13 +154,13 @@ public class ChartPage extends AbstractPage { var april = new XYChart.Series(); april.setName("April"); IntStream.range(1, 30).forEach(i -> april.getData().add( - new XYChart.Data<>(i, FAKER.random().nextInt(15, 30)) + new XYChart.Data<>(i, FAKER.random().nextInt(15, 30)) )); var may = new XYChart.Series(); may.setName("May"); IntStream.range(1, 30).forEach(i -> may.getData().add( - new XYChart.Data<>(i, FAKER.random().nextInt(15, 30)) + new XYChart.Data<>(i, FAKER.random().nextInt(15, 30)) )); var chart = stacked ? new StackedAreaChart<>(x, y) : new AreaChart<>(x, y); @@ -151,8 +174,8 @@ public class ChartPage extends AbstractPage { private Chart barChart(boolean stacked) { final var rnd = FAKER.random(); final var countries = IntStream.range(0, 5).boxed() - .map(i -> FAKER.country().countryCode3().toUpperCase()) - .toList(); + .map(i -> FAKER.country().countryCode3().toUpperCase()) + .toList(); var x = new CategoryAxis(); x.setLabel("Country"); @@ -163,19 +186,19 @@ public class ChartPage extends AbstractPage { var january = new XYChart.Series(); january.setName("January"); IntStream.range(0, countries.size()).forEach(i -> january.getData().add( - new XYChart.Data<>(countries.get(i), rnd.nextInt(10, 80)) + new XYChart.Data<>(countries.get(i), rnd.nextInt(10, 80)) )); var february = new XYChart.Series(); february.setName("February"); IntStream.range(0, countries.size()).forEach(i -> february.getData().add( - new XYChart.Data<>(countries.get(i), rnd.nextInt(10, 80)) + new XYChart.Data<>(countries.get(i), rnd.nextInt(10, 80)) )); var march = new XYChart.Series(); march.setName("March"); IntStream.range(0, countries.size()).forEach(i -> march.getData().add( - new XYChart.Data<>(countries.get(i), rnd.nextInt(10, 80)) + new XYChart.Data<>(countries.get(i), rnd.nextInt(10, 80)) )); var chart = stacked ? new StackedBarChart<>(x, y) : new BarChart<>(x, y); @@ -198,13 +221,13 @@ public class ChartPage extends AbstractPage { var series1 = new XYChart.Series(); series1.setName(FAKER.commerce().productName()); IntStream.range(1, 10).forEach(i -> series1.getData().add( - new XYChart.Data<>(rnd.nextInt(1, 53), rnd.nextInt(10, 80), rnd.nextDouble(1, 10)) + new XYChart.Data<>(rnd.nextInt(1, 53), rnd.nextInt(10, 80), rnd.nextDouble(1, 10)) )); var series2 = new XYChart.Series(); series2.setName(FAKER.commerce().productName()); IntStream.range(1, 10).forEach(i -> series2.getData().add( - new XYChart.Data<>(rnd.nextInt(1, 53), rnd.nextInt(10, 80), rnd.nextDouble(1, 10)) + new XYChart.Data<>(rnd.nextInt(1, 53), rnd.nextInt(10, 80), rnd.nextDouble(1, 10)) )); var chart = new BubbleChart<>(x, y); @@ -227,13 +250,13 @@ public class ChartPage extends AbstractPage { var series1 = new XYChart.Series(); series1.setName(FAKER.stock().nsdqSymbol()); IntStream.range(1, 12).forEach(i -> series1.getData().add( - new XYChart.Data<>(Month.of(i).getDisplayName(TextStyle.SHORT, Locale.getDefault()), rnd.nextInt(10, 80)) + new XYChart.Data<>(Month.of(i).getDisplayName(TextStyle.SHORT, Locale.getDefault()), rnd.nextInt(10, 80)) )); var series2 = new XYChart.Series(); series2.setName(FAKER.stock().nsdqSymbol()); IntStream.range(1, 12).forEach(i -> series2.getData().add( - new XYChart.Data<>(Month.of(i).getDisplayName(TextStyle.SHORT, Locale.getDefault()), rnd.nextInt(10, 80)) + new XYChart.Data<>(Month.of(i).getDisplayName(TextStyle.SHORT, Locale.getDefault()), rnd.nextInt(10, 80)) )); var chart = new LineChart<>(x, y); @@ -247,11 +270,11 @@ public class ChartPage extends AbstractPage { final var rnd = FAKER.random(); ObservableList data = FXCollections.observableArrayList( - new PieChart.Data(FAKER.food().fruit(), rnd.nextInt(10, 30)), - new PieChart.Data(FAKER.food().fruit(), rnd.nextInt(10, 30)), - new PieChart.Data(FAKER.food().fruit(), rnd.nextInt(10, 30)), - new PieChart.Data(FAKER.food().fruit(), rnd.nextInt(10, 30)), - new PieChart.Data(FAKER.food().fruit(), rnd.nextInt(10, 30)) + new PieChart.Data(FAKER.food().fruit(), rnd.nextInt(10, 30)), + new PieChart.Data(FAKER.food().fruit(), rnd.nextInt(10, 30)), + new PieChart.Data(FAKER.food().fruit(), rnd.nextInt(10, 30)), + new PieChart.Data(FAKER.food().fruit(), rnd.nextInt(10, 30)), + new PieChart.Data(FAKER.food().fruit(), rnd.nextInt(10, 30)) ); var chart = new PieChart(data); @@ -273,13 +296,13 @@ public class ChartPage extends AbstractPage { var series1 = new XYChart.Series(); series1.setName("Equities"); IntStream.range(1, 10).forEach(i -> series1.getData().add( - new XYChart.Data<>(rnd.nextDouble(0, 10), rnd.nextDouble(-100, 500)) + new XYChart.Data<>(rnd.nextDouble(0, 10), rnd.nextDouble(-100, 500)) )); var series2 = new XYChart.Series(); series2.setName("Mutual funds"); IntStream.range(1, 10).forEach(i -> series2.getData().add( - new XYChart.Data<>(rnd.nextDouble(0, 10), rnd.nextDouble(-100, 500)) + new XYChart.Data<>(rnd.nextDouble(0, 10), rnd.nextDouble(-100, 500)) )); var chart = new ScatterChart<>(x, y); @@ -311,9 +334,9 @@ public class ChartPage extends AbstractPage { public static Example find(String name) { return Arrays.stream(Example.values()) - .filter(example -> Objects.equals(example.getName(), name)) - .findFirst() - .orElse(null); + .filter(example -> Objects.equals(example.getName(), name)) + .findFirst() + .orElse(null); } } } diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/CheckBoxPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/CheckBoxPage.java index 07966a6..1098f18 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/CheckBoxPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/CheckBoxPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import atlantafx.sampler.page.AbstractPage; @@ -13,7 +14,9 @@ public class CheckBoxPage extends AbstractPage { public static final String NAME = "CheckBox"; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } private CheckBox basicCheck; private CheckBox indeterminateCheck; @@ -25,10 +28,10 @@ public class CheckBoxPage extends AbstractPage { private void createView() { setUserContent(new FlowPane( - PAGE_HGAP, PAGE_VGAP, - basicSample(), - indeterminateSample(), - disabledSample() + PAGE_HGAP, PAGE_VGAP, + basicSample(), + indeterminateSample(), + disabledSample() )); } @@ -57,8 +60,8 @@ public class CheckBoxPage extends AbstractPage { indeterminateCheck.setDisable(true); return new SampleBlock( - "Disabled", - new HBox(SampleBlock.BLOCK_HGAP, basicCheck, indeterminateCheck) + "Disabled", + new HBox(SampleBlock.BLOCK_HGAP, basicCheck, indeterminateCheck) ); } @@ -68,20 +71,22 @@ public class CheckBoxPage extends AbstractPage { var normalBox = basicCheck.lookup(".box"); var indeterminateBox = indeterminateCheck.lookup(".box"); - if (normalBox == null || indeterminateBox == null) { return; } + if (normalBox == null || indeterminateBox == null) { + return; + } // force layout to obtain node bounds ((StackPane) normalBox).layout(); ((StackPane) indeterminateBox).layout(); System.out.printf("Basic: height = %.2f , width = %.2f\n", - normalBox.getBoundsInParent().getHeight(), - normalBox.getBoundsInParent().getWidth() + normalBox.getBoundsInParent().getHeight(), + normalBox.getBoundsInParent().getWidth() ); System.out.printf("Indeterminate: height = %.2f , width = %.2f\n", - indeterminateBox.getBoundsInParent().getHeight(), - indeterminateBox.getBoundsInParent().getWidth() + indeterminateBox.getBoundsInParent().getHeight(), + indeterminateBox.getBoundsInParent().getWidth() ); } } diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/ColorPickerPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/ColorPickerPage.java index cc2c1ec..0576a03 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/ColorPickerPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/ColorPickerPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.sampler.page.SampleBlock.BLOCK_HGAP; @@ -21,12 +22,14 @@ public class ColorPickerPage extends AbstractPage { public static final String NAME = "ColorPicker"; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public ColorPickerPage() { super(); setUserContent(new VBox( - new SampleBlock("Playground", createPlayground()) + new SampleBlock("Playground", createPlayground()) )); } @@ -38,7 +41,9 @@ public class ColorPickerPage extends AbstractPage { labelToggle.setSelected(true); labelToggle.selectedProperty().addListener((obs, old, val) -> { colorPicker.setStyle("-fx-color-label-visible: false;"); - if (val) { colorPicker.setStyle("-fx-color-label-visible: true;"); } + if (val) { + colorPicker.setStyle("-fx-color-label-visible: true;"); + } }); var disableToggle = new ToggleSwitch(); @@ -56,9 +61,9 @@ public class ColorPickerPage extends AbstractPage { grid.add(disableToggle, 2, 2); grid.getColumnConstraints().setAll( - new ColumnConstraints(200), - new ColumnConstraints(), - new ColumnConstraints() + new ColumnConstraints(200), + new ColumnConstraints(), + new ColumnConstraints() ); return grid; @@ -78,11 +83,13 @@ public class ColorPickerPage extends AbstractPage { var choice = new ChoiceBox(); choice.getItems().setAll(optDefault, optButton, optSplitButton); choice.getSelectionModel().selectedItemProperty().addListener((obs, old, val) -> { - if (val == null) { return; } + if (val == null) { + return; + } colorPicker.getStyleClass().removeAll( - ColorPicker.STYLE_CLASS_BUTTON, - ColorPicker.STYLE_CLASS_SPLIT_BUTTON + ColorPicker.STYLE_CLASS_BUTTON, + ColorPicker.STYLE_CLASS_SPLIT_BUTTON ); if (optButton.equals(val)) { diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/ComboBoxPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/ComboBoxPage.java index 71e72b9..96cf29f 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/ComboBoxPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/ComboBoxPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.base.theme.Styles.STATE_DANGER; @@ -32,12 +33,14 @@ public class ComboBoxPage extends AbstractPage { private static final int PREF_WIDTH = 200; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public ComboBoxPage() { super(); setUserContent(new VBox( - new SampleBlock("Examples", createPlayground()) + new SampleBlock("Examples", createPlayground()) )); } @@ -73,8 +76,8 @@ public class ComboBoxPage extends AbstractPage { // with icons var badges = IntStream.range(0, 5).boxed() - .map(i -> new Badge(FAKER.hipster().word(), randomIcon())) - .collect(Collectors.toCollection(FXCollections::observableArrayList)); + .map(i -> new Badge(FAKER.hipster().word(), randomIcon())) + .collect(Collectors.toCollection(FXCollections::observableArrayList)); var badgeCombo = new ComboBox<>(badges); badgeCombo.setPrefWidth(PREF_WIDTH); badgeCombo.setButtonCell(new BadgeCell()); @@ -165,7 +168,9 @@ public class ComboBoxPage extends AbstractPage { private ComboBox createComboBoxWith(Consumer> mutator) { var c = new ComboBox(); c.setPrefWidth(PREF_WIDTH); - if (mutator != null) { mutator.accept(c); } + if (mutator != null) { + mutator.accept(c); + } return c; } @@ -176,7 +181,9 @@ public class ComboBoxPage extends AbstractPage { private ChoiceBox createChoiceBoxWith(Consumer> mutator) { var c = new ChoiceBox(); c.setPrefWidth(PREF_WIDTH); - if (mutator != null) { mutator.accept(c); } + if (mutator != null) { + mutator.accept(c); + } return c; } @@ -187,7 +194,8 @@ public class ComboBoxPage extends AbstractPage { /////////////////////////////////////////////////////////////////////////// @SuppressWarnings("unused") - private record Badge(String text, Ikon icon) { } + private record Badge(String text, Ikon icon) { + } private static class BadgeCell extends ListCell { diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/CustomTextFieldPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/CustomTextFieldPage.java index 84a0c3d..6000317 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/CustomTextFieldPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/CustomTextFieldPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.base.theme.Styles.STATE_DANGER; @@ -19,18 +20,20 @@ public class CustomTextFieldPage extends AbstractPage { private static final int PREF_WIDTH = 120; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public CustomTextFieldPage() { super(); setUserContent(new FlowPane( - PAGE_HGAP, PAGE_VGAP, - leftIconSample(), - rightIconSample(), - bothIconsSample(), - successSample(), - dangerSample(), - passwordSample() + PAGE_HGAP, PAGE_VGAP, + leftIconSample(), + rightIconSample(), + bothIconsSample(), + successSample(), + dangerSample(), + passwordSample() )); } diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/DatePickerPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/DatePickerPage.java index 34a9a2f..d10746e 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/DatePickerPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/DatePickerPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.base.theme.Styles.BUTTON_ICON; @@ -53,19 +54,21 @@ public class DatePickerPage extends AbstractPage { private static final int INLINE_DATE_PICKER_COL = 0; private static final int INLINE_DATE_PICKER_ROW = 4; private static final CSSFragment NO_YEAR_MONTH_STYLE = new CSSFragment(""" - .date-picker-popup >.month-year-pane { - visibility: hidden; - -fx-min-width: 0; - -fx-pref-width: 0; - -fx-max-width: 0; - -fx-min-height: 0; - -fx-pref-height: 0; - -fx-max-height: 0; - } - """); + .date-picker-popup >.month-year-pane { + visibility: hidden; + -fx-min-width: 0; + -fx-pref-width: 0; + -fx-max-width: 0; + -fx-min-height: 0; + -fx-pref-height: 0; + -fx-max-height: 0; + } + """); @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } private final BooleanProperty weekNumProperty = new SimpleBooleanProperty(); private final BooleanProperty showClockProperty = new SimpleBooleanProperty(); @@ -78,7 +81,7 @@ public class DatePickerPage extends AbstractPage { public DatePickerPage() { super(); setUserContent(new VBox( - new SampleBlock("Playground", createPlayground()) + new SampleBlock("Playground", createPlayground()) )); } @@ -114,14 +117,14 @@ public class DatePickerPage extends AbstractPage { var chronologyToggle = new ToggleSwitch("Second chronology"); chronologyToggle.selectedProperty().addListener( - (obs, old, val) -> popupDatePicker.setChronology(val ? HijrahChronology.INSTANCE : null) + (obs, old, val) -> popupDatePicker.setChronology(val ? HijrahChronology.INSTANCE : null) ); var editableToggle = new ToggleSwitch("Editable"); editableProperty.bind(editableToggle.selectedProperty()); // clear selected value to demonstrate prompt text editableProperty.addListener( - (obs, old, val) -> popupDatePicker.setValue(val ? null : TODAY) + (obs, old, val) -> popupDatePicker.setValue(val ? null : TODAY) ); var offPastDatesToggle = new ToggleSwitch("No past dates"); @@ -140,14 +143,14 @@ public class DatePickerPage extends AbstractPage { disableProperty.bind(disablePickerToggle.selectedProperty()); var controls = new VBox( - BLOCK_VGAP, - weekNumToggle, - showClockToggle, - showYearMonthToggle, - chronologyToggle, - editableToggle, - offPastDatesToggle, - disablePickerToggle + BLOCK_VGAP, + weekNumToggle, + showClockToggle, + showYearMonthToggle, + chronologyToggle, + editableToggle, + offPastDatesToggle, + disablePickerToggle ); controls.setAlignment(Pos.CENTER_RIGHT); @@ -193,7 +196,7 @@ public class DatePickerPage extends AbstractPage { datePicker.setBottomNode(colorSelector); datePicker.topNodeProperty().bind(Bindings.createObjectBinding( - () -> showClockProperty.get() ? clock : null, showClockProperty) + () -> showClockProperty.get() ? clock : null, showClockProperty) ); return datePicker; @@ -205,13 +208,17 @@ public class DatePickerPage extends AbstractPage { @Override public String toString(LocalDate localDate) { - if (localDate == null) { return ""; } + if (localDate == null) { + return ""; + } return DATE_FORMATTER.format(localDate); } @Override public LocalDate fromString(String dateString) { - if (dateString == null || dateString.trim().isEmpty()) { return null; } + if (dateString == null || dateString.trim().isEmpty()) { + return null; + } try { return LocalDate.parse(dateString, DATE_FORMATTER); } catch (Exception e) { @@ -233,26 +240,26 @@ public class DatePickerPage extends AbstractPage { public Clock() { var clockLabel = new Label( - TIME_FORMATTER.format(LocalTime.now(ZoneId.systemDefault())) + TIME_FORMATTER.format(LocalTime.now(ZoneId.systemDefault())) ); clockLabel.getStyleClass().add(Styles.TITLE_2); var dateLabel = new Label( - DateTimeFormatter.ofPattern("EEEE, LLLL dd, yyyy").format(LocalDate.now(ZoneId.systemDefault())) + DateTimeFormatter.ofPattern("EEEE, LLLL dd, yyyy").format(LocalDate.now(ZoneId.systemDefault())) ); setStyle(""" - -fx-border-width: 0 0 0.5 0; - -fx-border-color: -color-border-default;""" + -fx-border-width: 0 0 0.5 0; + -fx-border-color: -color-border-default;""" ); setSpacing(BLOCK_VGAP); getChildren().setAll(clockLabel, dateLabel); var t = new Timeline(new KeyFrame( - Duration.seconds(1), - e -> clockLabel.setText( - TIME_FORMATTER.format(LocalTime.now(ZoneId.systemDefault())) - ) + Duration.seconds(1), + e -> clockLabel.setText( + TIME_FORMATTER.format(LocalTime.now(ZoneId.systemDefault())) + ) )); t.setCycleCount(Animation.INDEFINITE); t.playFromStart(); @@ -277,16 +284,20 @@ public class DatePickerPage extends AbstractPage { resetBtn.setOnAction(e -> style.set(null)); style.addListener((obs, old, val) -> { - if (old != null) { old.removeFrom(parent); } - if (val != null) { val.addTo(parent); } + if (old != null) { + old.removeFrom(parent); + } + if (val != null) { + val.addTo(parent); + } }); setAlignment(Pos.CENTER); getChildren().setAll( - colorButton("-color-accent-emphasis", "-color-fg-emphasis"), - colorButton("-color-success-emphasis", "-color-fg-emphasis"), - colorButton("-color-danger-emphasis", "-color-fg-emphasis"), - resetBtn + colorButton("-color-accent-emphasis", "-color-fg-emphasis"), + colorButton("-color-success-emphasis", "-color-fg-emphasis"), + colorButton("-color-danger-emphasis", "-color-fg-emphasis"), + resetBtn ); getStyleClass().add("color-selector"); } @@ -305,19 +316,19 @@ public class DatePickerPage extends AbstractPage { private void updateStyle(String bgColorName, String fgColorName) { style.set(new CSSFragment(String.format(""" - .date-picker-popup { - -color-date-border: %s; - -color-date-month-year-bg: %s; - -color-date-month-year-fg: %s; - } - .date-picker-popup >.top-node { - -fx-background-color: %s; - -color-fg-default: %s; - -color-border-default: %s; - -fx-border-color: %s; - }""", - bgColorName, bgColorName, fgColorName, - bgColorName, fgColorName, fgColorName, fgColorName + .date-picker-popup { + -color-date-border: %s; + -color-date-month-year-bg: %s; + -color-date-month-year-fg: %s; + } + .date-picker-popup >.top-node { + -fx-background-color: %s; + -color-fg-default: %s; + -color-border-default: %s; + -fx-border-color: %s; + }""", + bgColorName, bgColorName, fgColorName, + bgColorName, fgColorName, fgColorName, fgColorName ))); } } diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/DialogPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/DialogPage.java index 7d69dce..cb131af 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/DialogPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/DialogPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.sampler.page.SampleBlock.BLOCK_HGAP; @@ -37,7 +38,9 @@ public class DialogPage extends AbstractPage { public static final String NAME = "Dialog"; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } private final BooleanProperty showHeaderProperty = new SimpleBooleanProperty(true); private final BooleanProperty minDecorationsProperty = new SimpleBooleanProperty(true); @@ -60,21 +63,21 @@ public class DialogPage extends AbstractPage { controls.setAlignment(Pos.CENTER); var samples = new FlowPane( - PAGE_HGAP, PAGE_VGAP, - infoDialogSample(), - warningDialogSample(), - errorDialogSample(), - exceptionDialogSample(), - confirmationDialogSample(), - textInputDialogSample(), - choiceDialogSample() + PAGE_HGAP, PAGE_VGAP, + infoDialogSample(), + warningDialogSample(), + errorDialogSample(), + exceptionDialogSample(), + confirmationDialogSample(), + textInputDialogSample(), + choiceDialogSample() ); setUserContent(new VBox( - 10, - controls, - new Separator(Orientation.HORIZONTAL), - samples + 10, + controls, + new Separator(Orientation.HORIZONTAL), + samples )); } diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/HTMLEditorPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/HTMLEditorPage.java index e79d7d3..451bc37 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/HTMLEditorPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/HTMLEditorPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.sampler.page.SampleBlock.BLOCK_VGAP; @@ -25,7 +26,9 @@ public class HTMLEditorPage extends AbstractPage { public static final String NAME = "HTMLEditor"; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } private HTMLEditor editor = createEditor(); @@ -46,9 +49,9 @@ public class HTMLEditorPage extends AbstractPage { private SampleBlock editorSample() { var description = new Text( - "HTMLEditor toolbar buttons use images from 'com/sun/javafx/scene/control/skin/modena'. " + - "In opposite, since AtlantaFX themes are also distributed as single CSS files, it contains no images. " + - "Unfortunately reusing Modena resources isn't possible, because the package isn't opened in OpenJFX 'module-info'." + "HTMLEditor toolbar buttons use images from 'com/sun/javafx/scene/control/skin/modena'. " + + "In opposite, since AtlantaFX themes are also distributed as single CSS files, it contains no images. " + + "Unfortunately reusing Modena resources isn't possible, because the package isn't opened in OpenJFX 'module-info'." ); var fixToggle = new ToggleSwitch("Apply Fix"); @@ -84,15 +87,15 @@ public class HTMLEditorPage extends AbstractPage { Theme samplerTheme = tm.getTheme(); HighlightJSTheme hlTheme = tm.getMatchingSourceCodeHighlightTheme(samplerTheme); return "" + - "" + - "" + - String.join("

", FAKER.lorem().paragraphs(10)) + - "" + - ""; + "" + + "" + + String.join("

", FAKER.lorem().paragraphs(10)) + + "" + + ""; } } diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/InputGroupPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/InputGroupPage.java index 55b1bc4..acb97a3 100755 --- a/sampler/src/main/java/atlantafx/sampler/page/components/InputGroupPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/InputGroupPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.base.theme.Styles.BUTTON_ICON; @@ -28,15 +29,17 @@ public class InputGroupPage extends AbstractPage { public static final String NAME = "Input Group"; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public InputGroupPage() { super(); setUserContent(new VBox( - Page.PAGE_VGAP, - expandingHBox(httpMethodSample(), passwordSample()), - expandingHBox(networkSample(), dropdownSample()), - labelSample() + Page.PAGE_VGAP, + expandingHBox(httpMethodSample(), passwordSample()), + expandingHBox(networkSample(), dropdownSample()), + labelSample() )); } @@ -156,10 +159,10 @@ public class InputGroupPage extends AbstractPage { // ~ var flowPane = new FlowPane( - BLOCK_HGAP, BLOCK_VGAP, - sample1, - sample2, - sample3 + BLOCK_HGAP, BLOCK_VGAP, + sample1, + sample2, + sample3 ); return new SampleBlock("Label & TextField", flowPane); diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/LabelPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/LabelPage.java index a5983be..53e6250 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/LabelPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/LabelPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.sampler.page.SampleBlock.BLOCK_HGAP; @@ -18,7 +19,9 @@ public class LabelPage extends AbstractPage { public static final String NAME = "Label"; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public LabelPage() { super(); @@ -27,8 +30,8 @@ public class LabelPage extends AbstractPage { private void createView() { setUserContent(new VBox( - PAGE_VGAP, - expandingHBox(colorSample()) + PAGE_VGAP, + expandingHBox(colorSample()) )); } @@ -54,14 +57,14 @@ public class LabelPage extends AbstractPage { subtleLabel.getStyleClass().add(Styles.TEXT_SUBTLE); var content = new VBox( - BLOCK_VGAP, - new Label("You can also use pseudo-classes to set Label color."), - new Label("Note that icon inherits label color by default."), - new FlowPane( - BLOCK_HGAP, BLOCK_VGAP, - defaultLabel, accentLabel, successLabel, warningLabel, dangerLabel, - mutedLabel, subtleLabel - )); + BLOCK_VGAP, + new Label("You can also use pseudo-classes to set Label color."), + new Label("Note that icon inherits label color by default."), + new FlowPane( + BLOCK_HGAP, BLOCK_VGAP, + defaultLabel, accentLabel, successLabel, warningLabel, dangerLabel, + mutedLabel, subtleLabel + )); return new SampleBlock("Colors", content); } diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/ListPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/ListPage.java index 5da2c5f..117a3e7 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/ListPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/ListPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.base.theme.Styles.ACCENT; @@ -45,7 +46,9 @@ public class ListPage extends AbstractPage { public static final String NAME = "ListView"; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } private final List dataList = generate(() -> Book.random(FAKER), 50); private final StringConverter bookStringConverter = new BookStringConverter(dataList); @@ -62,20 +65,26 @@ public class ListPage extends AbstractPage { private VBox createPlayground() { var borderedToggle = new ToggleSwitch("Bordered"); - borderedToggle.selectedProperty().addListener((obs, old, value) -> toggleListProperty(lv -> toggleStyleClass(lv, BORDERED))); + borderedToggle.selectedProperty() + .addListener((obs, old, value) -> toggleListProperty(lv -> toggleStyleClass(lv, BORDERED))); var denseToggle = new ToggleSwitch("Dense"); - denseToggle.selectedProperty().addListener((obs, old, value) -> toggleListProperty(lv -> toggleStyleClass(lv, DENSE))); + denseToggle.selectedProperty() + .addListener((obs, old, value) -> toggleListProperty(lv -> toggleStyleClass(lv, DENSE))); var stripedToggle = new ToggleSwitch("Striped"); - stripedToggle.selectedProperty().addListener((obs, old, value) -> toggleListProperty(lv -> toggleStyleClass(lv, STRIPED))); + stripedToggle.selectedProperty() + .addListener((obs, old, value) -> toggleListProperty(lv -> toggleStyleClass(lv, STRIPED))); var edge2edgeToggle = new ToggleSwitch("Edge to edge"); - edge2edgeToggle.selectedProperty().addListener((obs, old, value) -> toggleListProperty(lv -> toggleStyleClass(lv, Tweaks.EDGE_TO_EDGE))); + edge2edgeToggle.selectedProperty() + .addListener((obs, old, value) -> toggleListProperty(lv -> toggleStyleClass(lv, Tweaks.EDGE_TO_EDGE))); var disableToggle = new ToggleSwitch("Disable"); disableToggle.selectedProperty().addListener((obs, old, val) -> findDisplayedList().ifPresent(lv -> { - if (val != null) { lv.setDisable(val); } + if (val != null) { + lv.setDisable(val); + } })); var controls = new HBox(BLOCK_HGAP, borderedToggle, denseToggle, stripedToggle, edge2edgeToggle); @@ -84,11 +93,11 @@ public class ListPage extends AbstractPage { VBox.setVgrow(listWrapper, Priority.ALWAYS); var playground = new VBox( - BLOCK_VGAP, - new HBox(new Label("Select an example:"), new Spacer(), disableToggle), - exampleSelect, - listWrapper, - controls + BLOCK_VGAP, + new HBox(new Label("Select an example:"), new Spacer(), disableToggle), + exampleSelect, + listWrapper, + controls ); playground.setMinHeight(100); @@ -101,7 +110,9 @@ public class ListPage extends AbstractPage { select.getItems().setAll(Example.values()); select.getSelectionModel().selectedItemProperty().addListener((obs, old, val) -> { - if (val == null) { return; } + if (val == null) { + return; + } ListView newList = createList(val); @@ -139,24 +150,38 @@ public class ListPage extends AbstractPage { private Optional> findDisplayedList() { return listWrapper.getChildren().size() > 0 ? - Optional.of((ListView) listWrapper.getChildren().get(0)) : - Optional.empty(); + Optional.of((ListView) listWrapper.getChildren().get(0)) : + Optional.empty(); } private void toggleListProperty(Consumer> consumer) { findDisplayedList().ifPresent(lv -> { - if (consumer != null) { consumer.accept(lv); } + if (consumer != null) { + consumer.accept(lv); + } }); } private ListView createList(Example example) { switch (example) { - case TEXT -> { return stringList(); } - case EDITABLE -> { return editableList(); } - case CHECK_BOX -> { return checkBoxList(); } - case CHOICE_BOX -> { return choiceBoxList(); } - case COMBO_BOX -> { return comboBoxList(); } - case NESTED_CONTROLS -> { return nestedControlsList(); } + case TEXT -> { + return stringList(); + } + case EDITABLE -> { + return editableList(); + } + case CHECK_BOX -> { + return checkBoxList(); + } + case CHOICE_BOX -> { + return choiceBoxList(); + } + case COMBO_BOX -> { + return comboBoxList(); + } + case NESTED_CONTROLS -> { + return nestedControlsList(); + } default -> throw new IllegalArgumentException("Unexpected enum value: " + example); } } @@ -172,8 +197,8 @@ public class ListPage extends AbstractPage { lv.setEditable(true); lv.setCellFactory(TextFieldListCell.forListView()); lv.getItems().setAll( - // small size to see the empty cells - dataList.stream().limit(5).map(bookStringConverter::toString).collect(Collectors.toList()) + // small size to see the empty cells + dataList.stream().limit(5).map(bookStringConverter::toString).collect(Collectors.toList()) ); return lv; } @@ -188,7 +213,8 @@ public class ListPage extends AbstractPage { private ListView choiceBoxList() { var lv = new ListView(); lv.setEditable(true); - lv.setCellFactory(ChoiceBoxListCell.forListView(bookStringConverter, dataList.subList(0, 10).toArray(Book[]::new))); + lv.setCellFactory( + ChoiceBoxListCell.forListView(bookStringConverter, dataList.subList(0, 10).toArray(Book[]::new))); lv.getItems().setAll(dataList.stream().limit(10).collect(Collectors.toList())); return lv; } @@ -196,7 +222,8 @@ public class ListPage extends AbstractPage { private ListView comboBoxList() { var lv = new ListView(); lv.setEditable(true); - lv.setCellFactory(ComboBoxListCell.forListView(bookStringConverter, dataList.subList(0, 10).toArray(Book[]::new))); + lv.setCellFactory( + ComboBoxListCell.forListView(bookStringConverter, dataList.subList(0, 10).toArray(Book[]::new))); lv.getItems().setAll(dataList.stream().limit(10).collect(Collectors.toList())); return lv; } @@ -230,9 +257,9 @@ public class ListPage extends AbstractPage { public static Example find(String name) { return Arrays.stream(Example.values()) - .filter(example -> Objects.equals(example.getName(), name)) - .findFirst() - .orElse(null); + .filter(example -> Objects.equals(example.getName(), name)) + .findFirst() + .orElse(null); } } @@ -246,22 +273,26 @@ public class ListPage extends AbstractPage { @Override public String toString(Book book) { - if (book == null) { return null; } + if (book == null) { + return null; + } return String.format("\"%s\" by %s", book.getTitle(), book.getAuthor()); } @Override public Book fromString(String s) { - if (s == null) { return null; } + if (s == null) { + return null; + } int sep = s.indexOf("\" by"); String title = s.substring(1, sep); String author = s.substring(sep + "\" by".length()); return dataList.stream() - .filter(b -> Objects.equals(b.getTitle(), title) && Objects.equals(b.getAuthor(), author)) - .findFirst() - .orElse(null); + .filter(b -> Objects.equals(b.getTitle(), title) && Objects.equals(b.getAuthor(), author)) + .findFirst() + .orElse(null); } } @@ -280,11 +311,11 @@ public class ListPage extends AbstractPage { purchaseBtn.setGraphic(new FontIcon(Feather.SHOPPING_CART)); root = new HBox(5, - titleLabel, - new Label(" by"), - authorLink, - new Spacer(), - purchaseBtn + titleLabel, + new Label(" by"), + authorLink, + new Spacer(), + purchaseBtn ); root.setAlignment(Pos.CENTER_LEFT); } diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/MenuButtonPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/MenuButtonPage.java index 430dc77..f9be9fb 100755 --- a/sampler/src/main/java/atlantafx/sampler/page/components/MenuButtonPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/MenuButtonPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.base.theme.Styles.ACCENT; @@ -32,16 +33,18 @@ public class MenuButtonPage extends AbstractPage { private static final int PREF_WIDTH = 150; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public MenuButtonPage() { super(); setUserContent(new VBox( - Page.PAGE_VGAP, - expandingHBox(basicSample(), iconOnlySample()), - expandingHBox(coloredSample(), outlinedSample()), - expandingHBox(popupSideSample(), noArrowSample()), - disabledSample() + Page.PAGE_VGAP, + expandingHBox(basicSample(), iconOnlySample()), + expandingHBox(coloredSample(), outlinedSample()), + expandingHBox(popupSideSample(), noArrowSample()), + disabledSample() )); } @@ -272,7 +275,7 @@ public class MenuButtonPage extends AbstractPage { @SuppressWarnings("SameParameterValue") private MenuItem[] createItems(int count) { return IntStream.range(0, count) - .mapToObj(i -> new MenuItem(FAKER.babylon5().character())) - .toArray(MenuItem[]::new); + .mapToObj(i -> new MenuItem(FAKER.babylon5().character())) + .toArray(MenuItem[]::new); } } diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/MenuPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/MenuPage.java index bf7b628..6d006da 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/MenuPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/MenuPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static javafx.scene.input.KeyCombination.CONTROL_DOWN; @@ -23,13 +24,15 @@ public class MenuPage extends AbstractPage { public static final String NAME = "Menu"; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public MenuPage() { super(); setUserContent(new VBox(Page.PAGE_VGAP, - menuBarSample(), - contextMenuExample() + menuBarSample(), + contextMenuExample() )); } @@ -40,19 +43,21 @@ public class MenuPage extends AbstractPage { private SampleBlock contextMenuExample() { var contextMenu = new ContextMenu(); - var undoItem = Controls.menuItem("_Undo", Feather.CORNER_DOWN_LEFT, new KeyCodeCombination(KeyCode.Z, CONTROL_DOWN)); + var undoItem = + Controls.menuItem("_Undo", Feather.CORNER_DOWN_LEFT, new KeyCodeCombination(KeyCode.Z, CONTROL_DOWN)); undoItem.setMnemonicParsing(true); - var redoItem = Controls.menuItem("_Redo", Feather.CORNER_DOWN_RIGHT, new KeyCodeCombination(KeyCode.Y, CONTROL_DOWN)); + var redoItem = + Controls.menuItem("_Redo", Feather.CORNER_DOWN_RIGHT, new KeyCodeCombination(KeyCode.Y, CONTROL_DOWN)); redoItem.setMnemonicParsing(true); contextMenu.getItems().addAll( - undoItem, - redoItem, - new SeparatorMenuItem(), - Controls.menuItem("Cut", Feather.SCISSORS, new KeyCodeCombination(KeyCode.X, CONTROL_DOWN)), - Controls.menuItem("Copy", Feather.COPY, new KeyCodeCombination(KeyCode.C, CONTROL_DOWN)), - Controls.menuItem("Paste", null, new KeyCodeCombination(KeyCode.V, CONTROL_DOWN)) + undoItem, + redoItem, + new SeparatorMenuItem(), + Controls.menuItem("Cut", Feather.SCISSORS, new KeyCodeCombination(KeyCode.X, CONTROL_DOWN)), + Controls.menuItem("Copy", Feather.COPY, new KeyCodeCombination(KeyCode.C, CONTROL_DOWN)), + Controls.menuItem("Paste", null, new KeyCodeCombination(KeyCode.V, CONTROL_DOWN)) ); var content = new Label("Right-Click Here"); diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/OverviewPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/OverviewPage.java index 62065ab..4799104 100755 --- a/sampler/src/main/java/atlantafx/sampler/page/components/OverviewPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/OverviewPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.base.theme.Styles.ACCENT; @@ -55,19 +56,21 @@ public class OverviewPage extends AbstractPage { private static final int COMBO_BOX_WIDTH = 150; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public OverviewPage() { super(); setUserContent(new VBox( - PAGE_VGAP, - buttonSample(), - expandingHBox(iconButtonSample(), dropdownMenuSample()), - expandingHBox(checkBoxSample(), radioButtonSample(), toggleSwitchSample()), - comboBoxSample(), - sliderSample(), - expandingHBox(textFieldSample(), spinnerSample()), - textAreaSample() + PAGE_VGAP, + buttonSample(), + expandingHBox(iconButtonSample(), dropdownMenuSample()), + expandingHBox(checkBoxSample(), radioButtonSample(), toggleSwitchSample()), + comboBoxSample(), + sliderSample(), + expandingHBox(textFieldSample(), spinnerSample()), + textAreaSample() )); } @@ -306,7 +309,9 @@ public class OverviewPage extends AbstractPage { boolean selected, String... styleClasses) { var toggleButton = new ToggleButton(text); - if (group != null) { toggleButton.setToggleGroup(group); } + if (group != null) { + toggleButton.setToggleGroup(group); + } toggleButton.setSelected(selected); toggleButton.getStyleClass().addAll(styleClasses); @@ -315,7 +320,7 @@ public class OverviewPage extends AbstractPage { private MenuItem[] createMenuItems() { return IntStream.range(0, 5) - .mapToObj(i -> new MenuItem(FAKER.babylon5().character())) - .toArray(MenuItem[]::new); + .mapToObj(i -> new MenuItem(FAKER.babylon5().character())) + .toArray(MenuItem[]::new); } } diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/PaginationPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/PaginationPage.java index 2ebd3c2..631d6a5 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/PaginationPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/PaginationPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.sampler.page.SampleBlock.BLOCK_HGAP; @@ -23,12 +24,14 @@ public class PaginationPage extends AbstractPage { private static final int PREF_CONTROL_WIDTH = 120; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public PaginationPage() { super(); setUserContent(new VBox( - new SampleBlock("Playground", createPlayground()) + new SampleBlock("Playground", createPlayground()) )); } @@ -57,18 +60,22 @@ public class PaginationPage extends AbstractPage { var bulletToggle = new ToggleSwitch(); bulletToggle.selectedProperty().addListener( - (obs, old, val) -> Styles.toggleStyleClass(pagination, Pagination.STYLE_CLASS_BULLET) + (obs, old, val) -> Styles.toggleStyleClass(pagination, Pagination.STYLE_CLASS_BULLET) ); var showArrowsToggle = new ToggleSwitch(); showArrowsToggle.selectedProperty().addListener((obs, old, val) -> { - if (val != null) { pagination.setStyle(String.format("-fx-arrows-visible: %s;", val)); } + if (val != null) { + pagination.setStyle(String.format("-fx-arrows-visible: %s;", val)); + } }); showArrowsToggle.setSelected(true); var showPageInfoToggle = new ToggleSwitch(); showPageInfoToggle.selectedProperty().addListener((obs, old, val) -> { - if (val != null) { pagination.setStyle(String.format("-fx-page-information-visible: %s;", val)); } + if (val != null) { + pagination.setStyle(String.format("-fx-page-information-visible: %s;", val)); + } }); showPageInfoToggle.setSelected(true); diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/PopoverPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/PopoverPage.java index 553fa35..edf36c0 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/PopoverPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/PopoverPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.sampler.page.SampleBlock.BLOCK_HGAP; @@ -31,13 +32,15 @@ public class PopoverPage extends AbstractPage { public static final String NAME = "Popover"; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public PopoverPage() { super(); setUserContent(new VBox(Page.PAGE_VGAP, - new HBox(PAGE_HGAP, textSample(), datePickerSample(), dialogSample()), - positionSample() + new HBox(PAGE_HGAP, textSample(), datePickerSample(), dialogSample()), + positionSample() )); } @@ -64,14 +67,14 @@ public class PopoverPage extends AbstractPage { var link = createHyperlink("Click me"); link.setOnAction(e -> popover.show(link)); new CSSFragment(""" - .popover .date-picker-popup { - -color-date-border: transparent; - -color-date-bg: transparent; - -color-date-day-bg: transparent; - -color-date-month-year-bg: transparent; - -color-date-day-bg-hover: -color-bg-subtle; - } - """ + .popover .date-picker-popup { + -color-date-border: transparent; + -color-date-bg: transparent; + -color-date-day-bg: transparent; + -color-date-month-year-bg: transparent; + -color-date-day-bg-hover: -color-bg-subtle; + } + """ ).addTo(link); return new SampleBlock("Date Picker", link); @@ -86,7 +89,8 @@ public class PopoverPage extends AbstractPage { var icon = new FontIcon(Feather.ALERT_TRIANGLE); icon.setIconSize(32); // not always works - icon.setStyle("-fx-icon-size:32px;-fx-icon-color:-color-warning-fg;-fx-fill:-color-warning-fg;" + icon.getStyle()); + icon.setStyle( + "-fx-icon-size:32px;-fx-icon-color:-color-warning-fg;-fx-fill:-color-warning-fg;" + icon.getStyle()); var label = new Label(FAKER.chuckNorris().fact(), icon); label.setStyle("-fx-graphic-text-gap:10;"); diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/ProgressPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/ProgressPage.java index 9009dea..35fbac7 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/ProgressPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/ProgressPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.base.theme.Styles.BUTTON_CIRCLE; @@ -46,7 +47,9 @@ public class ProgressPage extends AbstractPage { public static final String NAME = "Progress"; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public ProgressPage() { super(); @@ -69,11 +72,11 @@ public class ProgressPage extends AbstractPage { private SampleBlock basicBarSample() { var flowPane = new FlowPane( - BLOCK_HGAP, BLOCK_VGAP, - createBar(0, false), - createBar(0.5, false), - createBar(1, false), - createBar(0.5, true) + BLOCK_HGAP, BLOCK_VGAP, + createBar(0, false), + createBar(0.5, false), + createBar(1, false), + createBar(0.5, true) ); flowPane.setAlignment(Pos.CENTER_LEFT); @@ -82,11 +85,11 @@ public class ProgressPage extends AbstractPage { private SampleBlock basicIndicatorSample() { var flowPane = new FlowPane( - BLOCK_HGAP, BLOCK_VGAP, - createIndicator(0, false), - createIndicator(0.5, false), - createIndicator(1, false), - createIndicator(0.5, true) + BLOCK_HGAP, BLOCK_VGAP, + createIndicator(0, false), + createIndicator(0.5, false), + createIndicator(1, false), + createIndicator(0.5, true) ); flowPane.setAlignment(Pos.TOP_LEFT); @@ -95,10 +98,10 @@ public class ProgressPage extends AbstractPage { private SampleBlock barSizeSample() { var container = new VBox( - BLOCK_VGAP, - new HBox(20, createBar(0.5, false, SMALL), new Text("small")), - new HBox(20, createBar(0.5, false, MEDIUM), new Text("medium")), - new HBox(20, createBar(0.5, false, LARGE), new Text("large")) + BLOCK_VGAP, + new HBox(20, createBar(0.5, false, SMALL), new Text("small")), + new HBox(20, createBar(0.5, false, MEDIUM), new Text("medium")), + new HBox(20, createBar(0.5, false, LARGE), new Text("large")) ); container.setAlignment(Pos.TOP_LEFT); container.getChildren().forEach(c -> ((HBox) c).setAlignment(Pos.CENTER_LEFT)); @@ -179,52 +182,52 @@ public class ProgressPage extends AbstractPage { grid.setHgap(40); grid.setVgap(BLOCK_VGAP); grid.getColumnConstraints().setAll( - new ColumnConstraints(-1, -1, -1, Priority.NEVER, HPos.CENTER, true), - new ColumnConstraints(-1, -1, -1, Priority.NEVER, HPos.CENTER, true), - new ColumnConstraints(-1, -1, -1, Priority.NEVER, HPos.CENTER, true) + new ColumnConstraints(-1, -1, -1, Priority.NEVER, HPos.CENTER, true), + new ColumnConstraints(-1, -1, -1, Priority.NEVER, HPos.CENTER, true), + new ColumnConstraints(-1, -1, -1, Priority.NEVER, HPos.CENTER, true) ); grid.getRowConstraints().setAll( - new RowConstraints(-1, -1, -1, Priority.ALWAYS, VPos.CENTER, true), - new RowConstraints(-1, -1, -1, Priority.NEVER, VPos.CENTER, true) + new RowConstraints(-1, -1, -1, Priority.ALWAYS, VPos.CENTER, true), + new RowConstraints(-1, -1, -1, Priority.NEVER, VPos.CENTER, true) ); var barToggle = new ToggleButton("Start"); barToggle.textProperty().bind(Bindings.createStringBinding( - () -> barToggle.isSelected() ? "Stop" : "Start", barToggle.selectedProperty()) + () -> barToggle.isSelected() ? "Stop" : "Start", barToggle.selectedProperty()) ); var bar = createBar(0, false); bar.progressProperty().bind(Bindings.createDoubleBinding( - () -> barToggle.isSelected() ? -1d : 0d, barToggle.selectedProperty()) + () -> barToggle.isSelected() ? -1d : 0d, barToggle.selectedProperty()) ); grid.add(bar, 0, 0); grid.add(barToggle, 0, 1); var indicatorToggle = new ToggleButton("Start"); indicatorToggle.textProperty().bind(Bindings.createStringBinding( - () -> indicatorToggle.isSelected() ? "Stop" : "Start", indicatorToggle.selectedProperty()) + () -> indicatorToggle.isSelected() ? "Stop" : "Start", indicatorToggle.selectedProperty()) ); var indicator = createIndicator(0, false); indicator.setPrefSize(75, 75); indicator.progressProperty().bind(Bindings.createDoubleBinding( - () -> indicatorToggle.isSelected() ? -1d : 0d, indicatorToggle.selectedProperty()) + () -> indicatorToggle.isSelected() ? -1d : 0d, indicatorToggle.selectedProperty()) ); grid.add(indicator, 1, 0); grid.add(indicatorToggle, 1, 1); var ringToggle = new ToggleButton("Start"); ringToggle.textProperty().bind(Bindings.createStringBinding( - () -> ringToggle.isSelected() ? "Stop" : "Start", ringToggle.selectedProperty()) + () -> ringToggle.isSelected() ? "Stop" : "Start", ringToggle.selectedProperty()) ); var ring = new RingProgressIndicator(0, false); ring.setMinSize(75, 75); ring.progressProperty().bind(Bindings.createDoubleBinding( - () -> ringToggle.isSelected() ? -1d : 0d, ringToggle.selectedProperty()) + () -> ringToggle.isSelected() ? -1d : 0d, ringToggle.selectedProperty()) ); grid.add(ring, 2, 0); grid.add(ringToggle, 2, 1); return new SampleBlock("Indeterminate", grid, - "Animated JavaFX progress indicators aren't cheap. They can consume quite a lot of CPU time." + "Animated JavaFX progress indicators aren't cheap. They can consume quite a lot of CPU time." ); } @@ -256,7 +259,9 @@ public class ProgressPage extends AbstractPage { content.setPrefHeight(200); bar.progressProperty().addListener((obs, old, val) -> { - if (val == null) { return; } + if (val == null) { + return; + } if (val.floatValue() > 0.80) { barStack.pseudoClassStateChanged(stateDanger, true); @@ -266,17 +271,17 @@ public class ProgressPage extends AbstractPage { }); new CSSFragment(""" - .example:state-success .progress-bar { - -color-progress-bar-fill: -color-success-emphasis; - } - .example:state-danger .progress-bar { - -color-progress-bar-fill: -color-danger-emphasis; - } - .example:state-success .label, - .example:state-danger .label { - -fx-text-fill: -color-fg-emphasis; - } - """).addTo(content); + .example:state-success .progress-bar { + -color-progress-bar-fill: -color-success-emphasis; + } + .example:state-danger .progress-bar { + -color-progress-bar-fill: -color-danger-emphasis; + } + .example:state-success .label, + .example:state-danger .label { + -fx-text-fill: -color-fg-emphasis; + } + """).addTo(content); runBtn.setOnAction(e1 -> { var task = new Task() { diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/RadioButtonPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/RadioButtonPage.java index 49ea629..f46dcc9 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/RadioButtonPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/RadioButtonPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.sampler.page.SampleBlock.BLOCK_VGAP; @@ -16,15 +17,17 @@ public class RadioButtonPage extends AbstractPage { public static final String NAME = "RadioButton"; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public RadioButtonPage() { super(); setUserContent(new FlowPane( - Page.PAGE_HGAP, Page.PAGE_VGAP, - basicSample(), - groupSample(), - disabledSample() + Page.PAGE_HGAP, Page.PAGE_VGAP, + basicSample(), + groupSample(), + disabledSample() )); } diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/ScrollPanePage.java b/sampler/src/main/java/atlantafx/sampler/page/components/ScrollPanePage.java index 358a44e..a22a5b4 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/ScrollPanePage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/ScrollPanePage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import atlantafx.sampler.page.AbstractPage; @@ -17,16 +18,18 @@ public class ScrollPanePage extends AbstractPage { private static final int SPACING = 1; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public ScrollPanePage() { super(); setUserContent(new FlowPane( - Page.PAGE_VGAP, Page.PAGE_HGAP, - horizontalScrollSample(), - verticalScrollSample(), - gridScrollSample(), - disabledSample() + Page.PAGE_VGAP, Page.PAGE_HGAP, + horizontalScrollSample(), + verticalScrollSample(), + gridScrollSample(), + disabledSample() )); } @@ -35,8 +38,8 @@ public class ScrollPanePage extends AbstractPage { scrollPane.setMaxHeight(100); scrollPane.setMaxWidth(300); scrollPane.setContent(new HBox(SPACING, - createRegion(200, 100, "-color-success-emphasis"), - createRegion(200, 100, "-color-danger-emphasis") + createRegion(200, 100, "-color-success-emphasis"), + createRegion(200, 100, "-color-danger-emphasis") )); scrollPane.setVbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); @@ -48,8 +51,8 @@ public class ScrollPanePage extends AbstractPage { scrollPane.setMaxHeight(100); scrollPane.setMaxWidth(300); scrollPane.setContent(new VBox(SPACING, - createRegion(300, 75, "-color-success-emphasis"), - createRegion(300, 75, "-color-danger-emphasis") + createRegion(300, 75, "-color-success-emphasis"), + createRegion(300, 75, "-color-danger-emphasis") )); scrollPane.setHbarPolicy(ScrollPane.ScrollBarPolicy.NEVER); diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/SeparatorPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/SeparatorPage.java index 425a7cb..0e3cd97 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/SeparatorPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/SeparatorPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static javafx.geometry.Orientation.HORIZONTAL; @@ -25,29 +26,31 @@ public final class SeparatorPage extends AbstractPage { private static final int PANE_SIZE = 100; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public SeparatorPage() { super(); setUserContent(new FlowPane( - Page.PAGE_HGAP, Page.PAGE_VGAP, - orientationSample(), - sizeSample() + Page.PAGE_HGAP, Page.PAGE_VGAP, + orientationSample(), + sizeSample() )); } private SampleBlock orientationSample() { var hBox = new HBox( - createPane("Left", VERTICAL), - new Separator(VERTICAL), - createPane("Right", VERTICAL) + createPane("Left", VERTICAL), + new Separator(VERTICAL), + createPane("Right", VERTICAL) ); hBox.setAlignment(CENTER); var vBox = new VBox( - createPane("Top", HORIZONTAL), - new Separator(HORIZONTAL), - createPane("Bottom", HORIZONTAL) + createPane("Top", HORIZONTAL), + new Separator(HORIZONTAL), + createPane("Bottom", HORIZONTAL) ); vBox.setAlignment(CENTER); @@ -58,27 +61,27 @@ public final class SeparatorPage extends AbstractPage { var smallSep = new Separator(VERTICAL); smallSep.getStyleClass().add(Styles.SMALL); var smallBox = new HBox( - createPane("Left", VERTICAL), - smallSep, - createPane("Right", VERTICAL) + createPane("Left", VERTICAL), + smallSep, + createPane("Right", VERTICAL) ); smallBox.setAlignment(CENTER); var mediumSep = new Separator(VERTICAL); mediumSep.getStyleClass().add(Styles.MEDIUM); var mediumBox = new HBox( - createPane("Left", VERTICAL), - mediumSep, - createPane("Right", VERTICAL) + createPane("Left", VERTICAL), + mediumSep, + createPane("Right", VERTICAL) ); mediumBox.setAlignment(CENTER); var largeSep = new Separator(VERTICAL); largeSep.getStyleClass().add(Styles.LARGE); var largeBox = new HBox( - createPane("Left", VERTICAL), - largeSep, - createPane("Right", VERTICAL) + createPane("Left", VERTICAL), + largeSep, + createPane("Right", VERTICAL) ); largeBox.setAlignment(CENTER); diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/SliderPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/SliderPage.java index 970a9b7..0a09e93 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/SliderPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/SliderPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static javafx.geometry.Orientation.VERTICAL; @@ -20,16 +21,18 @@ public class SliderPage extends AbstractPage { private static final int SPACING = 20; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public SliderPage() { super(); setUserContent(new FlowPane( - Page.PAGE_HGAP, Page.PAGE_VGAP, - basicSample(), - smallSample(), - largeSample(), - disabledSample() + Page.PAGE_HGAP, Page.PAGE_VGAP, + basicSample(), + smallSample(), + largeSample(), + disabledSample() )); } diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/SpinnerPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/SpinnerPage.java index 5b064e6..86c1cb8 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/SpinnerPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/SpinnerPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import atlantafx.base.util.IntegerStringConverter; @@ -14,19 +15,21 @@ public final class SpinnerPage extends AbstractPage { private static final int PREF_WIDTH = 120; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public SpinnerPage() { super(); setUserContent(new FlowPane( - Page.PAGE_HGAP, Page.PAGE_VGAP, - basicSample(), - arrowsLeftVerticalSample(), - arrowsLeftHorizontalSample(), - arrowsRightHorizontalSample(), - arrowsSplitHorizontalSample(), - arrowsSplitVerticalSample(), - disabledSample() + Page.PAGE_HGAP, Page.PAGE_VGAP, + basicSample(), + arrowsLeftVerticalSample(), + arrowsLeftHorizontalSample(), + arrowsRightHorizontalSample(), + arrowsSplitHorizontalSample(), + arrowsSplitVerticalSample(), + disabledSample() )); } diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/SplitPanePage.java b/sampler/src/main/java/atlantafx/sampler/page/components/SplitPanePage.java index a57d0f7..91418dc 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/SplitPanePage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/SplitPanePage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import atlantafx.sampler.page.AbstractPage; @@ -18,16 +19,18 @@ public class SplitPanePage extends AbstractPage { public static final String NAME = "SplitPane"; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public SplitPanePage() { super(); setUserContent(new FlowPane( - Page.PAGE_VGAP, Page.PAGE_HGAP, - hSplitSample(), - vSplitSample(), - disabledSample(), - gridSample() + Page.PAGE_VGAP, Page.PAGE_HGAP, + hSplitSample(), + vSplitSample(), + disabledSample(), + gridSample() )); } @@ -68,8 +71,12 @@ public class SplitPanePage extends AbstractPage { doubleSplitPane.setOrientation(Orientation.VERTICAL); doubleSplitPane.setDividerPositions(0.5); doubleSplitPane.getItems().setAll( - new VBox(topSplitPane) {{ setAlignment(Pos.CENTER); }}, - new VBox(bottomSplitPane) {{ setAlignment(Pos.CENTER); }} + new VBox(topSplitPane) {{ + setAlignment(Pos.CENTER); + }}, + new VBox(bottomSplitPane) {{ + setAlignment(Pos.CENTER); + }} ); doubleSplitPane.setMinSize(400, 200); doubleSplitPane.setMaxSize(400, 200); diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/TabPanePage.java b/sampler/src/main/java/atlantafx/sampler/page/components/TabPanePage.java index d9fc589..50458e5 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/TabPanePage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/TabPanePage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.base.theme.Styles.ACCENT; @@ -38,7 +39,9 @@ public class TabPanePage extends AbstractPage { private static final double TAB_MIN_HEIGHT = 60; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } private Side tabSide = Side.TOP; private boolean fullWidth = false; @@ -122,7 +125,9 @@ public class TabPanePage extends AbstractPage { var floatingToggle = new ToggleSwitch(); floatingToggle.selectedProperty().addListener((obs, old, val) -> { - if (val != null) { Styles.toggleStyleClass(tabs, TabPane.STYLE_CLASS_FLOATING); } + if (val != null) { + Styles.toggleStyleClass(tabs, TabPane.STYLE_CLASS_FLOATING); + } }); var animatedToggle = new ToggleSwitch(); @@ -148,7 +153,9 @@ public class TabPanePage extends AbstractPage { var disableToggle = new ToggleSwitch(); disableToggle.selectedProperty().addListener((obs, old, val) -> { - if (val != null) { tabs.setDisable(val); } + if (val != null) { + tabs.setDisable(val); + } }); var togglesGrid = new GridPane(); @@ -176,10 +183,10 @@ public class TabPanePage extends AbstractPage { // == LAYOUT == var controls = new HBox(40, - new Spacer(), - buttonsPane, - togglesGrid, - new Spacer() + new Spacer(), + buttonsPane, + togglesGrid, + new Spacer() ); controls.setAlignment(Pos.CENTER); @@ -208,16 +215,16 @@ public class TabPanePage extends AbstractPage { if (tabs.getSide() == Side.TOP || tabs.getSide() == Side.BOTTOM) { tabs.tabMinWidthProperty().bind(borderPane.widthProperty() - .subtract(18) // .control-buttons-tab width - .divide(tabs.getTabs().size()) - .subtract(28) // .tab paddings + .subtract(18) // .control-buttons-tab width + .divide(tabs.getTabs().size()) + .subtract(28) // .tab paddings ); } if (tabs.getSide() == Side.LEFT || tabs.getSide() == Side.RIGHT) { tabs.tabMinWidthProperty().bind(borderPane.heightProperty() - .subtract(18) // same as above - .divide(tabs.getTabs().size()) - .subtract(28) + .subtract(18) // same as above + .divide(tabs.getTabs().size()) + .subtract(28) ); } } @@ -231,16 +238,18 @@ public class TabPanePage extends AbstractPage { // like disabled. To prevent it from closing one can use "black hole" // event handler. #javafx-bug tabs.getTabs().addAll( - createRandomTab(), - createRandomTab(), - createRandomTab() + createRandomTab(), + createRandomTab(), + createRandomTab() ); return tabs; } private void rotateTabs(BorderPane borderPane, TabPane tabs, Side side) { - if (tabSide == side) { return; } + if (tabSide == side) { + return; + } borderPane.getChildren().removeAll(tabs); tabSide = side; diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/TablePage.java b/sampler/src/main/java/atlantafx/sampler/page/components/TablePage.java index 3a1a776..bed36e0 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/TablePage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/TablePage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.base.theme.Styles.BORDERED; @@ -59,12 +60,14 @@ public class TablePage extends AbstractPage { public static final String NAME = "TableView"; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } private TableView table; private final List dataList = IntStream.range(1, 51).boxed() - .map(i -> Product.random(i, FAKER)) - .toList(); + .map(i -> Product.random(i, FAKER)) + .toList(); public TablePage() { super(); @@ -88,7 +91,7 @@ public class TablePage extends AbstractPage { var edge2edgeToggle = new ToggleSwitch("Edge to edge"); edge2edgeToggle.selectedProperty().addListener( - (obs, old, value) -> toggleStyleClass(table, Tweaks.EDGE_TO_EDGE) + (obs, old, value) -> toggleStyleClass(table, Tweaks.EDGE_TO_EDGE) ); var maxRowCount = 100; @@ -99,14 +102,14 @@ public class TablePage extends AbstractPage { rowCountBox.setAlignment(Pos.CENTER_LEFT); var footer = new HBox( - BLOCK_HGAP, - new Spacer(), - bordersToggle, - denseToggle, - stripesToggle, - edge2edgeToggle, - new Spacer(), - rowCountBox + BLOCK_HGAP, + new Spacer(), + bordersToggle, + denseToggle, + stripesToggle, + edge2edgeToggle, + new Spacer(), + rowCountBox ); footer.setAlignment(Pos.CENTER_LEFT); @@ -114,8 +117,8 @@ public class TablePage extends AbstractPage { var filteredData = new FilteredList<>(observableArrayList(dataList)); filteredData.predicateProperty().bind(Bindings.createObjectBinding( - () -> product -> product.getId() <= rowCountChoice.getValue(), - rowCountChoice.valueProperty() + () -> product -> product.getId() <= rowCountChoice.getValue(), + rowCountChoice.valueProperty() )); var sortedData = new SortedList<>(filteredData); @@ -161,15 +164,17 @@ public class TablePage extends AbstractPage { var disableToggle = new ToggleSwitch("Disable"); disableToggle.selectedProperty().addListener((obs, old, val) -> { - if (val != null) { table.setDisable(val); } + if (val != null) { + table.setDisable(val); + } }); var header = new HBox( - createTablePropertiesMenu(table), - new Spacer(), - alignBox, - new Spacer(), - disableToggle + createTablePropertiesMenu(table), + new Spacer(), + alignBox, + new Spacer(), + disableToggle ); header.setAlignment(Pos.CENTER_LEFT); @@ -194,8 +199,8 @@ public class TablePage extends AbstractPage { indexCol.setCellFactory(col -> { TableCell cell = new TableCell<>(); StringBinding value = Bindings.when(cell.emptyProperty()) - .then("") - .otherwise(cell.indexProperty().add(1).asString()); + .then("") + .otherwise(cell.indexProperty().add(1).asString()); cell.textProperty().bind(value); return cell; }); @@ -208,14 +213,14 @@ public class TablePage extends AbstractPage { var brandCol = new TableColumn("Brand 🖉"); brandCol.setCellValueFactory(new PropertyValueFactory<>("brand")); brandCol.setCellFactory(ChoiceBoxTableCell.forTableColumn( - generate(() -> FAKER.commerce().brand(), 10).toArray(String[]::new) + generate(() -> FAKER.commerce().brand(), 10).toArray(String[]::new) )); brandCol.setEditable(true); var nameCol = new TableColumn("Name 🖉"); nameCol.setCellValueFactory(new PropertyValueFactory<>("name")); nameCol.setCellFactory(ComboBoxTableCell.forTableColumn( - generate(() -> FAKER.commerce().productName(), 10).toArray(String[]::new) + generate(() -> FAKER.commerce().productName(), 10).toArray(String[]::new) )); nameCol.setEditable(true); @@ -298,16 +303,16 @@ public class TablePage extends AbstractPage { return new MenuButton("Properties") {{ getItems().setAll( - resizePolicyCaption, - unconstrainedResizeItem, - constrainedResizeItem, - selectionModeCaption, - singleSelectionItem, - multiSelectionItem, - new SeparatorMenuItem(), - editCellsItem, - cellSelectionItem, - menuButtonItem + resizePolicyCaption, + unconstrainedResizeItem, + constrainedResizeItem, + selectionModeCaption, + singleSelectionItem, + multiSelectionItem, + new SeparatorMenuItem(), + editCellsItem, + cellSelectionItem, + menuButtonItem ); }}; } diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/TextAreaPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/TextAreaPage.java index ef6c56c..dba2e57 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/TextAreaPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/TextAreaPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.base.theme.Styles.STATE_DANGER; @@ -18,19 +19,21 @@ public class TextAreaPage extends AbstractPage { private static final double CONTROL_HEIGHT = 120; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public TextAreaPage() { super(); setUserContent(new FlowPane( - PAGE_HGAP, PAGE_VGAP, - basicSample(), - promptSample(), - scrollSample(), - readonlySample(), - successSample(), - dangerSample(), - disabledSample() + PAGE_HGAP, PAGE_VGAP, + basicSample(), + promptSample(), + scrollSample(), + readonlySample(), + successSample(), + dangerSample(), + disabledSample() )); } @@ -48,7 +51,7 @@ public class TextAreaPage extends AbstractPage { private SampleBlock scrollSample() { var textArea = createTextArea( - Stream.generate(() -> FAKER.lorem().paragraph()).limit(10).collect(Collectors.joining("\n")) + Stream.generate(() -> FAKER.lorem().paragraph()).limit(10).collect(Collectors.joining("\n")) ); textArea.setWrapText(false); return new SampleBlock("Scrolling", textArea); diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/TextFieldPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/TextFieldPage.java index 06fdbc1..5ccb8fe 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/TextFieldPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/TextFieldPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.base.theme.Styles.LARGE; @@ -21,16 +22,18 @@ public class TextFieldPage extends AbstractPage { public static final String NAME = "TextField"; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public TextFieldPage() { super(); setUserContent(new VBox( - PAGE_VGAP, - expandingHBox(basicSample(), promptSample(), passwordSample()), - expandingHBox(readonlySample(), successSample(), dangerSample()), - expandingHBox(sizeSample(), roundedSample()), - disabledSample() + PAGE_VGAP, + expandingHBox(basicSample(), promptSample(), passwordSample()), + expandingHBox(readonlySample(), successSample(), dangerSample()), + expandingHBox(sizeSample(), roundedSample()), + disabledSample() )); } diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/TitledPanePage.java b/sampler/src/main/java/atlantafx/sampler/page/components/TitledPanePage.java index 3cb0f4a..e838b94 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/TitledPanePage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/TitledPanePage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.base.theme.Styles.DENSE; @@ -35,7 +36,9 @@ public class TitledPanePage extends AbstractPage { private static final String ELEVATED_PREFIX = "elevated-"; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public TitledPanePage() { super(); @@ -44,17 +47,17 @@ public class TitledPanePage extends AbstractPage { private void createView() { var samples = new HBox( - PAGE_HGAP, - interactivePane(), - disabledPane(), - untitledPane() + PAGE_HGAP, + interactivePane(), + disabledPane(), + untitledPane() ); samples.getChildren().forEach(c -> ((TitledPane) c).setPrefSize(500, 120)); setUserContent(new VBox( - Page.PAGE_VGAP, - createPlayground(), - samples + Page.PAGE_VGAP, + createPlayground(), + samples )); } @@ -80,11 +83,15 @@ public class TitledPanePage extends AbstractPage { elevationSlider.setMaxWidth(150); elevationSlider.valueProperty().addListener((obs, old, val) -> { playground.getStyleClass().removeAll( - playground.getStyleClass().stream().filter(c -> c.startsWith(ELEVATED_PREFIX)).toList() + playground.getStyleClass().stream().filter(c -> c.startsWith(ELEVATED_PREFIX)).toList() ); - if (val == null) { return; } + if (val == null) { + return; + } int level = val.intValue(); - if (level > 0) { playground.getStyleClass().add(ELEVATED_PREFIX + level); } + if (level > 0) { + playground.getStyleClass().add(ELEVATED_PREFIX + level); + } }); // NOTE: @@ -108,8 +115,8 @@ public class TitledPanePage extends AbstractPage { toggles.setVgap(10); toggles.setHgap(BLOCK_HGAP); toggles.getColumnConstraints().setAll( - new ColumnConstraints(-1, -1, -1, NEVER, RIGHT, false), - new ColumnConstraints(-1, -1, -1, NEVER, RIGHT, false) + new ColumnConstraints(-1, -1, -1, NEVER, RIGHT, false), + new ColumnConstraints(-1, -1, -1, NEVER, RIGHT, false) ); toggles.add(collapseToggle, 0, 0); toggles.add(animateToggle, 1, 0); @@ -121,10 +128,10 @@ public class TitledPanePage extends AbstractPage { controls.setFillHeight(false); controls.setAlignment(Pos.CENTER_LEFT); controls.getChildren().setAll( - new Label("Elevation"), - elevationSlider, - new Spacer(), - toggles + new Label("Elevation"), + elevationSlider, + new Spacer(), + toggles ); var content = new VBox(BLOCK_VGAP, textFlow, controls); diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/ToggleButtonPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/ToggleButtonPage.java index dbd3e8b..4273be3 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/ToggleButtonPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/ToggleButtonPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.base.theme.Styles.BUTTON_ICON; @@ -25,7 +26,9 @@ public class ToggleButtonPage extends AbstractPage { public static final String NAME = "ToggleButton"; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public ToggleButtonPage() { super(); @@ -61,8 +64,8 @@ public class ToggleButtonPage extends AbstractPage { var twoButtonGroup = new ToggleGroup(); var twoButtonBox = new HBox( - toggleButton(".left-pill", null, twoButtonGroup, true, LEFT_PILL), - toggleButton(".right-pill", null, twoButtonGroup, false, RIGHT_PILL) + toggleButton(".left-pill", null, twoButtonGroup, true, LEFT_PILL), + toggleButton(".right-pill", null, twoButtonGroup, false, RIGHT_PILL) ); return new SampleBlock("Basic", new HBox(BLOCK_HGAP, threeButtonBox, twoButtonBox)); @@ -91,14 +94,16 @@ public class ToggleButtonPage extends AbstractPage { }); var wizard = new HBox( - prevBtn, - toggleButton("Music", Feather.MUSIC, group, true, CENTER_PILL), - toggleButton("Images", Feather.IMAGE, group, false, CENTER_PILL), - toggleButton("Videos", Feather.VIDEO, group, false, CENTER_PILL), - nextBtn + prevBtn, + toggleButton("Music", Feather.MUSIC, group, true, CENTER_PILL), + toggleButton("Images", Feather.IMAGE, group, false, CENTER_PILL), + toggleButton("Videos", Feather.VIDEO, group, false, CENTER_PILL), + nextBtn ); group.selectedToggleProperty().addListener((obs, old, val) -> { - if (val == null) { old.setSelected(true); } + if (val == null) { + old.setSelected(true); + } }); return new SampleBlock("Wizard", wizard); @@ -106,9 +111,9 @@ public class ToggleButtonPage extends AbstractPage { private SampleBlock iconOnlySample() { var icons = new HBox( - toggleButton("", Feather.BOLD, null, true, BUTTON_ICON, LEFT_PILL), - toggleButton("", Feather.ITALIC, null, false, BUTTON_ICON, CENTER_PILL), - toggleButton("", Feather.UNDERLINE, null, false, BUTTON_ICON, RIGHT_PILL) + toggleButton("", Feather.BOLD, null, true, BUTTON_ICON, LEFT_PILL), + toggleButton("", Feather.ITALIC, null, false, BUTTON_ICON, CENTER_PILL), + toggleButton("", Feather.UNDERLINE, null, false, BUTTON_ICON, RIGHT_PILL) ); return new SampleBlock("Icon only", icons); @@ -117,9 +122,9 @@ public class ToggleButtonPage extends AbstractPage { private SampleBlock disabledSample() { var group = new ToggleGroup(); var content = new HBox( - toggleButton(".left-pill", null, group, false, LEFT_PILL), - toggleButton(".center-pill", null, group, false, CENTER_PILL), - toggleButton(".right-pill", null, group, true, RIGHT_PILL) + toggleButton(".left-pill", null, group, false, LEFT_PILL), + toggleButton(".center-pill", null, group, false, CENTER_PILL), + toggleButton(".right-pill", null, group, true, RIGHT_PILL) ); content.getChildren().get(0).setDisable(true); content.getChildren().get(1).setDisable(true); diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/ToggleSwitchPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/ToggleSwitchPage.java index d5819d0..8ba6c03 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/ToggleSwitchPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/ToggleSwitchPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import atlantafx.base.controls.ToggleSwitch; @@ -12,13 +13,15 @@ public class ToggleSwitchPage extends AbstractPage { public static final String NAME = "ToggleSwitch"; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public ToggleSwitchPage() { super(); setUserContent(new FlowPane( - Page.PAGE_HGAP, Page.PAGE_VGAP, - basicSample() + Page.PAGE_HGAP, Page.PAGE_VGAP, + basicSample() )); } diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/ToolBarPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/ToolBarPage.java index 4ec46eb..4e21879 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/ToolBarPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/ToolBarPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.base.theme.Styles.ACCENT; @@ -57,7 +58,9 @@ public class ToolBarPage extends AbstractPage { public static final String NAME = "ToolBar"; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } private Side toolbarPos = Side.TOP; @@ -149,7 +152,9 @@ public class ToolBarPage extends AbstractPage { var disableToggle = new ToggleSwitch(); disableToggle.selectedProperty().addListener((obs, old, val) -> { - if (val != null) { toolbar.setDisable(val); } + if (val != null) { + toolbar.setDisable(val); + } }); var togglesGrid = new GridPane(); @@ -178,13 +183,17 @@ public class ToolBarPage extends AbstractPage { } private void rotateToolbar(BorderPane borderPane, ToolBar toolbar, Side pos) { - if (toolbarPos == pos) { return; } + if (toolbarPos == pos) { + return; + } var topBar = (TopBar) borderPane.getTop(); toolbarPos = pos; boolean changed = borderPane.getChildren().removeAll(toolbar); - if (!changed) { topBar.removeToolBar(); } + if (!changed) { + topBar.removeToolBar(); + } // WARNING: // Rotating existing buttons seems tempting, but it won't work. @@ -270,7 +279,8 @@ public class ToolBarPage extends AbstractPage { } public static MenuItem[] createItems(int count) { - return IntStream.range(0, count).mapToObj(i -> new MenuItem(FAKER.babylon5().character())).toArray(MenuItem[]::new); + return IntStream.range(0, count).mapToObj(i -> new MenuItem(FAKER.babylon5().character())) + .toArray(MenuItem[]::new); } /////////////////////////////////////////////////////////////////////////// diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/TooltipPage.java b/sampler/src/main/java/atlantafx/sampler/page/components/TooltipPage.java index 42fdad4..2c1453b 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/TooltipPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/TooltipPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.sampler.page.SampleBlock.BLOCK_HGAP; @@ -23,17 +24,19 @@ public class TooltipPage extends AbstractPage { public static final String NAME = "Tooltip"; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public TooltipPage() { super(); setUserContent(new VBox(Page.PAGE_VGAP, - expandingHBox( - basicSample(), - textWrapSample(), - indefiniteSample() - ), - positionSample() + expandingHBox( + basicSample(), + textWrapSample(), + indefiniteSample() + ), + positionSample() )); } @@ -83,14 +86,14 @@ public class TooltipPage extends AbstractPage { bottomRightLabel.setTooltip(createTooltip("Bottom Right", AnchorLocation.WINDOW_TOP_LEFT)); var flowPane = new FlowPane( - BLOCK_HGAP, BLOCK_VGAP, - topLeftLabel, - new Separator(VERTICAL), - topRightLabel, - new Separator(VERTICAL), - bottomLeftLabel, - new Separator(VERTICAL), - bottomRightLabel + BLOCK_HGAP, BLOCK_VGAP, + topLeftLabel, + new Separator(VERTICAL), + topRightLabel, + new Separator(VERTICAL), + bottomLeftLabel, + new Separator(VERTICAL), + bottomRightLabel ); return new SampleBlock("Position", flowPane); diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/TreePage.java b/sampler/src/main/java/atlantafx/sampler/page/components/TreePage.java index ac91cd0..42b05cc 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/TreePage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/TreePage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.base.theme.Styles.DENSE; @@ -38,10 +39,12 @@ public class TreePage extends AbstractPage { public static final String NAME = "TreeView"; private static final int MAX_TREE_DEPTH = 3; - private static final int[] TREE_DICE = { -1, 0, 1 }; + private static final int[] TREE_DICE = {-1, 0, 1}; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } private final BorderPane treeWrapper = new BorderPane(); private final ComboBox exampleSelect = createExampleSelect(); @@ -57,28 +60,32 @@ public class TreePage extends AbstractPage { private VBox createPlayground() { var denseToggle = new ToggleSwitch("Dense"); denseToggle.selectedProperty().addListener( - (obs, old, value) -> findDisplayedTree().ifPresent(tv -> toggleStyleClass(tv, DENSE)) + (obs, old, value) -> findDisplayedTree().ifPresent(tv -> toggleStyleClass(tv, DENSE)) ); var showRootToggle = new ToggleSwitch("Show root"); showRootToggle.selectedProperty().addListener((obs, old, val) -> findDisplayedTree().ifPresent(tv -> { - if (val != null) { tv.setShowRoot(val); } + if (val != null) { + tv.setShowRoot(val); + } })); showRootToggle.setSelected(true); var altIconToggle = new ToggleSwitch("Alt icon"); altIconToggle.selectedProperty().addListener((obs, old, val) -> - findDisplayedTree().ifPresent(tv -> toggleStyleClass(tv, Tweaks.ALT_ICON)) + findDisplayedTree().ifPresent(tv -> toggleStyleClass(tv, Tweaks.ALT_ICON)) ); var edge2edgeToggle = new ToggleSwitch("Edge to edge"); edge2edgeToggle.selectedProperty().addListener( - (obs, old, val) -> findDisplayedTree().ifPresent(tv -> toggleStyleClass(tv, Tweaks.EDGE_TO_EDGE)) + (obs, old, val) -> findDisplayedTree().ifPresent(tv -> toggleStyleClass(tv, Tweaks.EDGE_TO_EDGE)) ); var disableToggle = new ToggleSwitch("Disable"); disableToggle.selectedProperty().addListener((obs, old, val) -> findDisplayedTree().ifPresent(tv -> { - if (val != null) { tv.setDisable(val); } + if (val != null) { + tv.setDisable(val); + } })); var controls = new HBox(BLOCK_HGAP, denseToggle, showRootToggle, altIconToggle, edge2edgeToggle); @@ -87,11 +94,11 @@ public class TreePage extends AbstractPage { VBox.setVgrow(treeWrapper, Priority.ALWAYS); var playground = new VBox( - BLOCK_VGAP, - new HBox(new Label("Select an example:"), new Spacer(), disableToggle), - exampleSelect, - treeWrapper, - controls + BLOCK_VGAP, + new HBox(new Label("Select an example:"), new Spacer(), disableToggle), + exampleSelect, + treeWrapper, + controls ); playground.setMinHeight(100); @@ -103,7 +110,9 @@ public class TreePage extends AbstractPage { select.setMaxWidth(Double.MAX_VALUE); select.getItems().setAll(Example.values()); select.getSelectionModel().selectedItemProperty().addListener((obs, old, val) -> { - if (val == null) { return; } + if (val == null) { + return; + } TreeView newTree = createTree(val); @@ -142,24 +151,38 @@ public class TreePage extends AbstractPage { private Optional> findDisplayedTree() { return treeWrapper.getChildren().size() > 0 ? - Optional.of((TreeView) treeWrapper.getChildren().get(0)) : - Optional.empty(); + Optional.of((TreeView) treeWrapper.getChildren().get(0)) : + Optional.empty(); } private TreeView createTree(Example example) { switch (example) { - case TEXT -> { return stringTree(); } - case GRAPHIC -> { return graphicTree(); } - case EDITABLE -> { return editableTree(); } - case CHECK_BOX -> { return checkBoxTree(); } - case CHOICE_BOX -> { return choiceBoxTree(); } - case COMBO_BOX -> { return comboBoxTree(); } + case TEXT -> { + return stringTree(); + } + case GRAPHIC -> { + return graphicTree(); + } + case EDITABLE -> { + return editableTree(); + } + case CHECK_BOX -> { + return checkBoxTree(); + } + case CHOICE_BOX -> { + return choiceBoxTree(); + } + case COMBO_BOX -> { + return comboBoxTree(); + } default -> throw new IllegalArgumentException("Unexpected enum value: " + example); } } private void generateTree(TreeItem parent, Supplier> supplier, int limit, int depth) { - if (limit == 0) { return; } + if (limit == 0) { + return; + } var item = supplier.get(); parent.getChildren().add(item); @@ -239,7 +262,7 @@ public class TreePage extends AbstractPage { var tree = new TreeView(); tree.setCellFactory(ChoiceBoxTreeCell.forTreeView( - generate(() -> FAKER.internet().domainWord(), 10).toArray(String[]::new) + generate(() -> FAKER.internet().domainWord(), 10).toArray(String[]::new) )); tree.setEditable(true); @@ -255,7 +278,7 @@ public class TreePage extends AbstractPage { var tree = new TreeView(); tree.setCellFactory(ComboBoxTreeCell.forTreeView( - generate(() -> FAKER.internet().domainWord(), 10).toArray(String[]::new) + generate(() -> FAKER.internet().domainWord(), 10).toArray(String[]::new) )); tree.setEditable(true); @@ -287,9 +310,9 @@ public class TreePage extends AbstractPage { public static Example find(String name) { return Arrays.stream(Example.values()) - .filter(example -> Objects.equals(example.getName(), name)) - .findFirst() - .orElse(null); + .filter(example -> Objects.equals(example.getName(), name)) + .findFirst() + .orElse(null); } } } diff --git a/sampler/src/main/java/atlantafx/sampler/page/components/TreeTablePage.java b/sampler/src/main/java/atlantafx/sampler/page/components/TreeTablePage.java index 5108431..a5b3763 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/components/TreeTablePage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/components/TreeTablePage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.components; import static atlantafx.base.theme.Styles.BORDERED; @@ -50,7 +51,9 @@ public class TreeTablePage extends AbstractPage { public static final String NAME = "TreeTableView"; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } private TreeTableView treeTable; @@ -79,7 +82,7 @@ public class TreeTablePage extends AbstractPage { var edge2edgeToggle = new ToggleSwitch("Edge to edge"); edge2edgeToggle.selectedProperty().addListener( - (obs, old, value) -> toggleStyleClass(treeTable, Tweaks.EDGE_TO_EDGE) + (obs, old, value) -> toggleStyleClass(treeTable, Tweaks.EDGE_TO_EDGE) ); var footer = new HBox(BLOCK_HGAP, bordersToggle, denseToggle, stripesToggle, altIconToggle, edge2edgeToggle); @@ -98,7 +101,7 @@ public class TreeTablePage extends AbstractPage { var group = new TreeItem<>(groupVal); group.getChildren().setAll( - createTreeItems(idx * 100, FAKER.random().nextInt(5, 10), brand) + createTreeItems(idx * 100, FAKER.random().nextInt(5, 10), brand) ); root.getChildren().add(group); } @@ -143,15 +146,17 @@ public class TreeTablePage extends AbstractPage { var disableToggle = new ToggleSwitch("Disable"); disableToggle.selectedProperty().addListener((obs, old, val) -> { - if (val != null) { treeTable.setDisable(val); } + if (val != null) { + treeTable.setDisable(val); + } }); var header = new HBox( - createPropertiesMenu(treeTable), - new Spacer(), - alignBox, - new Spacer(), - disableToggle + createPropertiesMenu(treeTable), + new Spacer(), + alignBox, + new Spacer(), + disableToggle ); header.setAlignment(Pos.CENTER_LEFT); @@ -165,9 +170,9 @@ public class TreeTablePage extends AbstractPage { private List> createTreeItems(int startId, int count, String brand) { return IntStream.range(startId, startId + count + 1).boxed() - .map(id -> Product.random(id, brand, FAKER)) - .map(TreeItem::new) - .toList(); + .map(id -> Product.random(id, brand, FAKER)) + .map(TreeItem::new) + .toList(); } @SuppressWarnings("unchecked") @@ -189,7 +194,7 @@ public class TreeTablePage extends AbstractPage { idCol.setCellValueFactory(cell -> { Product product = cell.getValue().getValue(); return new SimpleStringProperty( - product != null && product.getId() != 0 ? String.valueOf(product.getId()) : "" + product != null && product.getId() != 0 ? String.valueOf(product.getId()) : "" ); }); idCol.setEditable(false); @@ -198,14 +203,14 @@ public class TreeTablePage extends AbstractPage { var brandCol = new TreeTableColumn("Brand 🖉"); brandCol.setCellValueFactory(new TreeItemPropertyValueFactory<>("brand")); brandCol.setCellFactory(ChoiceBoxTreeTableCell.forTreeTableColumn( - generate(() -> FAKER.commerce().brand(), 10).toArray(String[]::new) + generate(() -> FAKER.commerce().brand(), 10).toArray(String[]::new) )); brandCol.setEditable(true); var nameCol = new TreeTableColumn("Name 🖉"); nameCol.setCellValueFactory(new TreeItemPropertyValueFactory<>("name")); nameCol.setCellFactory(ComboBoxTreeTableCell.forTreeTableColumn( - generate(() -> FAKER.commerce().productName(), 10).toArray(String[]::new) + generate(() -> FAKER.commerce().productName(), 10).toArray(String[]::new) )); nameCol.setEditable(true); nameCol.setMinWidth(200); @@ -281,17 +286,17 @@ public class TreeTablePage extends AbstractPage { return new MenuButton("Properties") {{ getItems().setAll( - resizePolicyCaption, - unconstrainedResizeItem, - constrainedResizeItem, - selectionModeCaption, - singleSelectionItem, - multiSelectionItem, - new SeparatorMenuItem(), - showRootItem, - editCellsItem, - cellSelectionItem, - menuButtonItem + resizePolicyCaption, + unconstrainedResizeItem, + constrainedResizeItem, + selectionModeCaption, + singleSelectionItem, + multiSelectionItem, + new SeparatorMenuItem(), + showRootItem, + editCellsItem, + cellSelectionItem, + menuButtonItem ); }}; } diff --git a/sampler/src/main/java/atlantafx/sampler/page/general/AccentColorSelector.java b/sampler/src/main/java/atlantafx/sampler/page/general/AccentColorSelector.java index 2fd3191..3137563 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/general/AccentColorSelector.java +++ b/sampler/src/main/java/atlantafx/sampler/page/general/AccentColorSelector.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.general; import static atlantafx.base.theme.Styles.BUTTON_ICON; @@ -28,10 +29,10 @@ public class AccentColorSelector extends HBox { setAlignment(Pos.CENTER_LEFT); getChildren().setAll( - colorButton(AccentColor.primerPurple()), - colorButton(AccentColor.primerPink()), - colorButton(AccentColor.primerCoral()), - resetBtn + colorButton(AccentColor.primerPurple()), + colorButton(AccentColor.primerPink()), + colorButton(AccentColor.primerCoral()), + resetBtn ); getStyleClass().add("color-selector"); } diff --git a/sampler/src/main/java/atlantafx/sampler/page/general/ColorPalette.java b/sampler/src/main/java/atlantafx/sampler/page/general/ColorPalette.java index 771c71e..57d4531 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/general/ColorPalette.java +++ b/sampler/src/main/java/atlantafx/sampler/page/general/ColorPalette.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.general; import static atlantafx.sampler.util.Controls.hyperlink; @@ -47,25 +48,26 @@ class ColorPalette extends VBox { var noteText = new VBox(6); noteText.getChildren().setAll( - new TextFlow( - new Text("Color contrast between text and its background must meet "), - hyperlink("required WCAG standards", - URI.create("https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html") - ), - new Text(":") + new TextFlow( + new Text("Color contrast between text and its background must meet "), + hyperlink( + "required WCAG standards", + URI.create("https://www.w3.org/WAI/WCAG21/Understanding/contrast-minimum.html") ), - new Text(" • 4.5:1 for normal text"), - new Text(" • 3:1 for large text (>24px)"), - new Text(" • 3:1 for UI elements and graphics"), - new Text(" • no contrast requirement for decorative and disabled elements"), - new Text(), - new Text("Click on any color block to observe and modify color combination via built-in contrast checker.") + new Text(":") + ), + new Text(" • 4.5:1 for normal text"), + new Text(" • 3:1 for large text (>24px)"), + new Text(" • 3:1 for UI elements and graphics"), + new Text(" • no contrast requirement for decorative and disabled elements"), + new Text(), + new Text("Click on any color block to observe and modify color combination via built-in contrast checker.") ); var colorGrid = colorGrid(); backgroundProperty().addListener((obs, old, val) -> bgBaseColor.set( - val != null && !val.getFills().isEmpty() ? (Color) val.getFills().get(0).getFill() : Color.WHITE + val != null && !val.getFills().isEmpty() ? (Color) val.getFills().get(0).getFill() : Color.WHITE )); getChildren().setAll(headerBox, noteText, colorGrid); @@ -86,7 +88,9 @@ class ColorPalette extends VBox { grid.add(colorBlock("-color-fg-default", "-color-accent-muted", "-color-accent-emphasis"), 2, 1); grid.add(colorBlock("-color-accent-fg", "-color-accent-subtle", "-color-accent-emphasis"), 3, 1); - grid.add(colorBlock("-color-fg-emphasis", "-color-neutral-emphasis-plus", "-color-neutral-emphasis-plus"), 0, 2); + grid.add( + colorBlock("-color-fg-emphasis", "-color-neutral-emphasis-plus", "-color-neutral-emphasis-plus"), 0, 2 + ); grid.add(colorBlock("-color-fg-emphasis", "-color-neutral-emphasis", "-color-neutral-emphasis"), 1, 2); grid.add(colorBlock("-color-fg-default", "-color-neutral-muted", "-color-neutral-emphasis"), 2, 2); grid.add(colorBlock("-color-fg-default", "-color-neutral-subtle", "-color-neutral-emphasis"), 3, 2); diff --git a/sampler/src/main/java/atlantafx/sampler/page/general/ColorPaletteBlock.java b/sampler/src/main/java/atlantafx/sampler/page/general/ColorPaletteBlock.java index 905a785..4b1d1c8 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/general/ColorPaletteBlock.java +++ b/sampler/src/main/java/atlantafx/sampler/page/general/ColorPaletteBlock.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.general; import static atlantafx.base.theme.Styles.TITLE_3; @@ -64,7 +65,7 @@ class ColorPaletteBlock extends VBox { colorRectangle = new AnchorPane(); colorRectangle.setStyle( - String.format("-fx-background-color:%s;-fx-border-color:%s;", bgColorName, borderColorName) + String.format("-fx-background-color:%s;-fx-border-color:%s;", bgColorName, borderColorName) ); colorRectangle.getStyleClass().add("rectangle"); colorRectangle.getChildren().setAll(contrastRatioText, contrastLevelLabel, editIcon); @@ -78,7 +79,7 @@ class ColorPaletteBlock extends VBox { toggleHover(true); editIcon.setFill(getColorLuminance(flattenColor(bgBaseColor.get(), bgFill)) < LUMINANCE_THRESHOLD ? - Color.WHITE : Color.BLACK + Color.WHITE : Color.BLACK ); }); colorRectangle.setOnMouseExited(e -> toggleHover(false)); @@ -89,10 +90,10 @@ class ColorPaletteBlock extends VBox { }); getChildren().addAll( - colorRectangle, - colorNameText(fgColorName), - colorNameText(bgColorName), - colorNameText(borderColorName) + colorRectangle, + colorNameText(fgColorName), + colorNameText(bgColorName), + colorNameText(borderColorName) ); getStyleClass().add("block"); } @@ -116,7 +117,9 @@ class ColorPaletteBlock extends VBox { colorRectangle.pseudoClassStateChanged(PASSED, ContrastLevel.AA_NORMAL.satisfies(contrastRatio)); contrastRatioText.setText(String.format("%.2f", contrastRatio)); - contrastLevelIcon.setIconCode(ContrastLevel.AA_NORMAL.satisfies(contrastRatio) ? Material2AL.CHECK : Material2AL.CLOSE); + contrastLevelIcon.setIconCode( + ContrastLevel.AA_NORMAL.satisfies(contrastRatio) ? Material2AL.CHECK : Material2AL.CLOSE + ); contrastLevelLabel.setVisible(true); contrastLevelLabel.setText(ContrastLevel.AAA_NORMAL.satisfies(contrastRatio) ? "AAA" : "AA"); } @@ -127,7 +130,7 @@ class ColorPaletteBlock extends VBox { public Color getBgColor() { return colorRectangle.getBackground() != null && !colorRectangle.getBackground().isEmpty() ? - (Color) colorRectangle.getBackground().getFills().get(0).getFill() : null; + (Color) colorRectangle.getBackground().getFills().get(0).getFill() : null; } public String getFgColorName() { diff --git a/sampler/src/main/java/atlantafx/sampler/page/general/ColorScale.java b/sampler/src/main/java/atlantafx/sampler/page/general/ColorScale.java index 6f18179..3639dc0 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/general/ColorScale.java +++ b/sampler/src/main/java/atlantafx/sampler/page/general/ColorScale.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.general; import atlantafx.base.theme.Styles; @@ -21,12 +22,12 @@ class ColorScale extends VBox { private final ReadOnlyObjectWrapper bgBaseColor = new ReadOnlyObjectWrapper<>(Color.WHITE); private final List blocks = Arrays.asList( - ColorScaleBlock.forColorPrefix(bgBaseColor, "-color-base-", 10), - ColorScaleBlock.forColorPrefix(bgBaseColor, "-color-accent-", 10), - ColorScaleBlock.forColorPrefix(bgBaseColor, "-color-success-", 10), - ColorScaleBlock.forColorPrefix(bgBaseColor, "-color-warning-", 10), - ColorScaleBlock.forColorPrefix(bgBaseColor, "-color-danger-", 10), - ColorScaleBlock.forColorName(bgBaseColor, "-color-dark", "-color-light") + ColorScaleBlock.forColorPrefix(bgBaseColor, "-color-base-", 10), + ColorScaleBlock.forColorPrefix(bgBaseColor, "-color-accent-", 10), + ColorScaleBlock.forColorPrefix(bgBaseColor, "-color-success-", 10), + ColorScaleBlock.forColorPrefix(bgBaseColor, "-color-warning-", 10), + ColorScaleBlock.forColorPrefix(bgBaseColor, "-color-danger-", 10), + ColorScaleBlock.forColorName(bgBaseColor, "-color-dark", "-color-light") ); public ColorScale() { @@ -44,18 +45,20 @@ class ColorScale extends VBox { headerBox.getStyleClass().add("header"); var noteText = new TextFlow( - new Text("Avoid referencing scale variables directly when building UI that needs to adapt to different color themes. Instead, use the functional variables listed above.") + new Text( + "Avoid referencing scale variables directly when building UI that needs to adapt to different color themes. Instead, use the functional variables listed above." + ) ); backgroundProperty().addListener((obs, old, val) -> bgBaseColor.set( - val != null && !val.getFills().isEmpty() ? (Color) val.getFills().get(0).getFill() : Color.WHITE + val != null && !val.getFills().isEmpty() ? (Color) val.getFills().get(0).getFill() : Color.WHITE )); setId("color-scale"); getChildren().setAll( - headerBox, - noteText, - colorTable() + headerBox, + noteText, + colorTable() ); } diff --git a/sampler/src/main/java/atlantafx/sampler/page/general/ColorScaleBlock.java b/sampler/src/main/java/atlantafx/sampler/page/general/ColorScaleBlock.java index f9301af..2a9cacf 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/general/ColorScaleBlock.java +++ b/sampler/src/main/java/atlantafx/sampler/page/general/ColorScaleBlock.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.general; import static atlantafx.sampler.util.ContrastLevel.getColorLuminance; @@ -34,8 +35,8 @@ class ColorScaleBlock extends VBox { if (c instanceof Label label) { String colorName = (String) label.getUserData(); label.setStyle(String.format("-fx-background-color:%s;-fx-text-fill:%s;", - colorName, - JColorUtils.toHexWithAlpha(getSafeFgColor(label)) + colorName, + JColorUtils.toHexWithAlpha(getSafeFgColor(label)) )); } }); @@ -67,7 +68,7 @@ class ColorScaleBlock extends VBox { private Color getBgColor(Label label) { return label.getBackground() != null && !label.getBackground().isEmpty() ? - (Color) label.getBackground().getFills().get(0).getFill() : Color.WHITE; + (Color) label.getBackground().getFills().get(0).getFill() : Color.WHITE; } /////////////////////////////////////////////////////////////////////////// diff --git a/sampler/src/main/java/atlantafx/sampler/page/general/ContrastChecker.java b/sampler/src/main/java/atlantafx/sampler/page/general/ContrastChecker.java index da68f08..1c7db5d 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/general/ContrastChecker.java +++ b/sampler/src/main/java/atlantafx/sampler/page/general/ContrastChecker.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.general; import static atlantafx.sampler.page.general.ColorPaletteBlock.validateColorName; @@ -76,10 +77,10 @@ class ContrastChecker extends GridPane { this.bgBaseColor = bgBaseColor; this.contrastRatio = Bindings.createDoubleBinding( - () -> getContrastRatioOpacityAware(bgColor.getColor(), fgColor.getColor(), bgBaseColor.get()), - bgColor.colorProperty(), - fgColor.colorProperty(), - bgBaseColor + () -> getContrastRatioOpacityAware(bgColor.getColor(), fgColor.getColor(), bgBaseColor.get()), + bgColor.colorProperty(), + fgColor.colorProperty(), + bgBaseColor ); createView(); @@ -96,22 +97,35 @@ class ContrastChecker extends GridPane { setForeground(fgColor); } - public String getBgColorName() { return bgColorName; } + public String getBgColorName() { + return bgColorName; + } - public String getFgColorName() { return fgColorName; } + public String getFgColorName() { + return fgColorName; + } - public Color getBgColor() { return bgColor.colorProperty().get(); } + public Color getBgColor() { + return bgColor.colorProperty().get(); + } - public Color getFgColor() { return fgColor.colorProperty().get(); } + public Color getFgColor() { + return fgColor.colorProperty().get(); + } - public ReadOnlyObjectProperty bgColorProperty() { return bgColor.colorProperty(); } + public ReadOnlyObjectProperty bgColorProperty() { + return bgColor.colorProperty(); + } - public ReadOnlyObjectProperty fgColorProperty() { return fgColor.colorProperty(); } + public ReadOnlyObjectProperty fgColorProperty() { + return fgColor.colorProperty(); + } // Returns fg color that guaranteed to be visible on the current bg. public Color getSafeFgColor() { if (contrastRatio.get() <= CONTRAST_RATIO_THRESHOLD) { - return getColorLuminance(flattenColor(bgBaseColor.get(), bgColor.getColor())) < LUMINANCE_THRESHOLD ? Color.WHITE : Color.BLACK; + return getColorLuminance(flattenColor(bgBaseColor.get(), bgColor.getColor())) < LUMINANCE_THRESHOLD ? + Color.WHITE : Color.BLACK; } else { return fgColor.getColor(); } @@ -124,7 +138,7 @@ class ContrastChecker extends GridPane { var contrastRatioLabel = new Label("0.0"); contrastRatioLabel.getStyleClass().add("ratio"); contrastRatioLabel.textProperty().bind(Bindings.createStringBinding( - () -> String.format("%.2f", contrastRatio.get()), contrastRatio + () -> String.format("%.2f", contrastRatio.get()), contrastRatio )); var contrastRatioBox = new HBox(20, largeFontLabel, contrastRatioLabel); @@ -148,7 +162,9 @@ class ContrastChecker extends GridPane { var contrastLevels = new HBox(20, aaNormalBox, aaLargeBox, aaaNormalBox, aaaLargeBox); contrastRatio.addListener((obs, old, val) -> { - if (val == null) { return; } + if (val == null) { + return; + } float ratio = val.floatValue(); updateContrastLevelLabel(aaNormalLabel, ContrastLevel.AA_NORMAL.satisfies(ratio)); updateContrastLevelLabel(aaLargeLabel, ContrastLevel.AA_LARGE.satisfies(ratio)); @@ -166,7 +182,7 @@ class ContrastChecker extends GridPane { bgTextField.setEditable(false); bgTextField.setLeft(new FontIcon(Feather.HASH)); bgTextField.textProperty().bind(Bindings.createStringBinding( - () -> bgColor.getColorHexWithAlpha().substring(1), bgColor.colorProperty() + () -> bgColor.getColorHexWithAlpha().substring(1), bgColor.colorProperty() )); bgTextField.setContextMenu(new RightClickMenu(bgColor)); @@ -178,82 +194,98 @@ class ContrastChecker extends GridPane { fgTextField.setEditable(false); fgTextField.setLeft(new FontIcon(Feather.HASH)); fgTextField.textProperty().bind(Bindings.createStringBinding( - () -> fgColor.getColorHexWithAlpha().substring(1), fgColor.colorProperty() + () -> fgColor.getColorHexWithAlpha().substring(1), fgColor.colorProperty() )); fgTextField.setContextMenu(new RightClickMenu(fgColor)); bgHueSlider = slider(1, 360, 1, 1); bgHueSlider.valueProperty().addListener((obs, old, val) -> { - if (val != null) { bgColor.setHue(val.floatValue()); } + if (val != null) { + bgColor.setHue(val.floatValue()); + } }); var bgHueLabel = new Label("Hue °"); bgHueLabel.textProperty().bind(Bindings.createStringBinding( - () -> String.format("Hue %.0f °", bgHueSlider.getValue()), bgHueSlider.valueProperty()) + () -> String.format("Hue %.0f °", bgHueSlider.getValue()), bgHueSlider.valueProperty()) ); bgSaturationSlider = slider(0, 1, 0, 0.01); bgSaturationSlider.valueProperty().addListener((obs, old, val) -> { - if (val != null) { bgColor.setSaturation(val.floatValue()); } + if (val != null) { + bgColor.setSaturation(val.floatValue()); + } }); var bgSaturationLabel = new Label("Saturation"); bgSaturationLabel.textProperty().bind(Bindings.createStringBinding( - () -> String.format("Saturation %.2f", bgSaturationSlider.getValue()), bgSaturationSlider.valueProperty()) + () -> String.format("Saturation %.2f", bgSaturationSlider.getValue()), bgSaturationSlider.valueProperty()) ); bgLightnessSlider = slider(0, 1, 0, 0.01); bgLightnessSlider.valueProperty().addListener((obs, old, val) -> { - if (val != null) { bgColor.setLightness(val.floatValue()); } + if (val != null) { + bgColor.setLightness(val.floatValue()); + } }); var bgLightnessLabel = new Label("Lightness"); bgLightnessLabel.textProperty().bind(Bindings.createStringBinding( - () -> String.format("Lightness %.2f", bgLightnessSlider.getValue()), bgLightnessSlider.valueProperty()) + () -> String.format("Lightness %.2f", bgLightnessSlider.getValue()), bgLightnessSlider.valueProperty()) ); bgAlphaSlider = slider(0, 1, 0, 0.01); bgAlphaSlider.valueProperty().addListener((obs, old, val) -> { - if (val != null) { bgColor.setAlpha(val.floatValue()); } + if (val != null) { + bgColor.setAlpha(val.floatValue()); + } }); var bgAlphaLabel = new Label("Alpha"); bgAlphaLabel.textProperty().bind(Bindings.createStringBinding( - () -> String.format("Alpha %.2f", bgAlphaSlider.getValue()), bgAlphaSlider.valueProperty()) + () -> String.format("Alpha %.2f", bgAlphaSlider.getValue()), bgAlphaSlider.valueProperty()) ); // ~ fgHueSlider = slider(1, 360, 1, 1); fgHueSlider.valueProperty().addListener((obs, old, val) -> { - if (val != null) { fgColor.setHue(val.floatValue()); } + if (val != null) { + fgColor.setHue(val.floatValue()); + } }); var fgHueLabel = new Label("Hue °"); fgHueLabel.textProperty().bind(Bindings.createStringBinding( - () -> String.format("Hue %.0f °", fgHueSlider.getValue()), fgHueSlider.valueProperty()) + () -> String.format("Hue %.0f °", fgHueSlider.getValue()), fgHueSlider.valueProperty()) ); fgSaturationSlider = slider(0, 1, 0, 0.01); fgSaturationSlider.valueProperty().addListener((obs, old, val) -> { - if (val != null) { fgColor.setSaturation(val.floatValue()); } + if (val != null) { + fgColor.setSaturation(val.floatValue()); + } }); var fgSaturationLabel = new Label("Saturation"); fgSaturationLabel.textProperty().bind(Bindings.createStringBinding( - () -> String.format("Saturation %.2f", fgSaturationSlider.getValue()), fgSaturationSlider.valueProperty()) + () -> String.format("Saturation %.2f", fgSaturationSlider.getValue()), fgSaturationSlider.valueProperty()) ); fgLightnessSlider = slider(0, 1, 0, 0.01); fgLightnessSlider.valueProperty().addListener((obs, old, val) -> { - if (val != null) { fgColor.setLightness(val.floatValue()); } + if (val != null) { + fgColor.setLightness(val.floatValue()); + } }); var fgLightnessLabel = new Label("Lightness"); fgLightnessLabel.textProperty().bind(Bindings.createStringBinding( - () -> String.format("Lightness %.2f", fgLightnessSlider.getValue()), fgLightnessSlider.valueProperty()) + () -> String.format("Lightness %.2f", fgLightnessSlider.getValue()), fgLightnessSlider.valueProperty()) ); fgAlphaSlider = slider(0, 1, 0, 0.01); fgAlphaSlider.valueProperty().addListener((obs, old, val) -> { - if (val != null) { fgColor.setAlpha(val.floatValue()); } + if (val != null) { + fgColor.setAlpha(val.floatValue()); + } }); var fgAlphaLabel = new Label("Alpha"); fgAlphaLabel.textProperty().bind(Bindings.createStringBinding( - () -> String.format("Alpha %.2f", fgAlphaSlider.getValue()), fgAlphaSlider.valueProperty()) + () -> String.format("Alpha %.2f", fgAlphaSlider.getValue()), fgAlphaSlider.valueProperty()) ); // ~ @@ -269,8 +301,8 @@ class ContrastChecker extends GridPane { var applyBtn = new Button("Apply"); applyBtn.setOnAction(e -> ThemeManager.getInstance().setNamedColors(Map.of( - getBgColorName(), bgColor.getColor(), - getFgColorName(), fgColor.getColor() + getBgColorName(), bgColor.getColor(), + getFgColorName(), fgColor.getColor() ))); var actionsBox = new HBox(20, new Spacer(), flattenBtn, applyBtn); @@ -312,18 +344,22 @@ class ContrastChecker extends GridPane { add(fgAlphaSlider, 1, 11); bgColor.colorProperty().addListener((obs, old, val) -> { - if (val != null) { updateStyle(); } + if (val != null) { + updateStyle(); + } }); fgColor.colorProperty().addListener((obs, old, val) -> { - if (val != null) { updateStyle(); } + if (val != null) { + updateStyle(); + } }); } private void updateStyle() { setStyle(String.format("-color-contrast-checker-bg:%s;-color-contrast-checker-fg:%s;", - toHexWithAlpha(bgColor.getColor()), - toHexWithAlpha(getSafeFgColor()) + toHexWithAlpha(bgColor.getColor()), + toHexWithAlpha(getSafeFgColor()) )); } @@ -385,7 +421,8 @@ class ContrastChecker extends GridPane { private static class ObservableHSLAColor { private final ObservableList values = FXCollections.observableArrayList(0f, 0f, 0f, 0f); - private final ReadOnlyObjectWrapper color = new ReadOnlyObjectWrapper<>() { }; + private final ReadOnlyObjectWrapper color = new ReadOnlyObjectWrapper<>() { + }; public ObservableHSLAColor(Color initialColor) { values.addListener((ListChangeListener) c -> { @@ -441,18 +478,18 @@ class ContrastChecker extends GridPane { } public float[] getRGBAArithmeticColor() { - float[] hsl = new float[] { getHue(), getSaturation(), getLightness() }; + float[] hsl = new float[] {getHue(), getSaturation(), getLightness()}; var color = JColor.color(hsl, getAlpha()); return new float[] { - color.getRedArithmetic(), - color.getGreenArithmetic(), - color.getBlueArithmetic(), - getAlpha() + color.getRedArithmetic(), + color.getGreenArithmetic(), + color.getBlueArithmetic(), + getAlpha() }; } public String getColorHexWithAlpha() { - float[] hsl = new float[] { getHue(), getSaturation(), getLightness() }; + float[] hsl = new float[] {getHue(), getSaturation(), getLightness()}; return JColor.color(hsl, getAlpha()).getColorHexWithAlpha(); } } @@ -472,28 +509,33 @@ class ContrastChecker extends GridPane { private void createMenu() { var hexItem = new MenuItem("Copy as HEX"); hexItem.setOnAction(e -> { - var c = JColor.color(new float[] {color.getHue(), color.getSaturation(), color.getLightness(), color.getAlpha()}); + var c = JColor.color( + new float[] {color.getHue(), color.getSaturation(), color.getLightness(), color.getAlpha()}); PlatformUtils.copyToClipboard(color.getAlpha() < 1 ? - toHexWithAlpha(color.getColor()) : - c.getColorHex() + toHexWithAlpha(color.getColor()) : + c.getColorHex() ); }); var rgbItem = new MenuItem("Copy as RGB"); rgbItem.setOnAction(e -> { - var c = JColor.color(new float[] {color.getHue(), color.getSaturation(), color.getLightness(), color.getAlpha()}); + var c = JColor.color( + new float[] {color.getHue(), color.getSaturation(), color.getLightness(), color.getAlpha()}); PlatformUtils.copyToClipboard(color.getAlpha() < 1 ? - String.format("rgba(%d,%d,%d, %.1f)", c.getGreen(), c.getGreen(), c.getBlue(), c.getAlphaArithmetic()) : - String.format("rgb(%d,%d,%d)", c.getGreen(), c.getGreen(), c.getBlue()) + String.format("rgba(%d,%d,%d, %.1f)", c.getGreen(), c.getGreen(), c.getBlue(), + c.getAlphaArithmetic()) : + String.format("rgb(%d,%d,%d)", c.getGreen(), c.getGreen(), c.getBlue()) ); }); var hslItem = new MenuItem("Copy as HSL"); hslItem.setOnAction(e -> { - var c = JColor.color(new float[] {color.getHue(), color.getSaturation(), color.getLightness(), color.getAlpha()}); + var c = JColor.color( + new float[] {color.getHue(), color.getSaturation(), color.getLightness(), color.getAlpha()}); PlatformUtils.copyToClipboard(color.getAlpha() < 1 ? - String.format("hsla(%.0f,%.2f,%.2f, %.1f)", c.getHue(), c.getSaturation(), c.getLightness(), c.getAlphaArithmetic()) : - String.format("hsl(%.0f,%.2f,%.2f)", c.getHue(), c.getSaturation(), c.getLightness()) + String.format("hsla(%.0f,%.2f,%.2f, %.1f)", c.getHue(), c.getSaturation(), c.getLightness(), + c.getAlphaArithmetic()) : + String.format("hsl(%.0f,%.2f,%.2f)", c.getHue(), c.getSaturation(), c.getLightness()) ); }); diff --git a/sampler/src/main/java/atlantafx/sampler/page/general/ContrastCheckerDialog.java b/sampler/src/main/java/atlantafx/sampler/page/general/ContrastCheckerDialog.java index c75a59c..aaee84e 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/general/ContrastCheckerDialog.java +++ b/sampler/src/main/java/atlantafx/sampler/page/general/ContrastCheckerDialog.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.general; import atlantafx.sampler.page.OverlayDialog; @@ -25,8 +26,8 @@ class ContrastCheckerDialog extends OverlayDialog { private void updateStyle() { setStyle(String.format("-color-dialog-bg:%s;-color-dialog-fg:%s;", - JColorUtils.toHexWithAlpha(contrastChecker.getBgColor()), - JColorUtils.toHexWithAlpha(contrastChecker.getSafeFgColor()) + JColorUtils.toHexWithAlpha(contrastChecker.getBgColor()), + JColorUtils.toHexWithAlpha(contrastChecker.getSafeFgColor()) )); } diff --git a/sampler/src/main/java/atlantafx/sampler/page/general/IconBrowser.java b/sampler/src/main/java/atlantafx/sampler/page/general/IconBrowser.java index 1779a27..9a8b0df 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/general/IconBrowser.java +++ b/sampler/src/main/java/atlantafx/sampler/page/general/IconBrowser.java @@ -70,8 +70,8 @@ public class IconBrowser extends TableView> { private void updateData(String filterString) { var displayedIcons = filterString == null || filterString.isBlank() || filterString.length() < FILTER_LEN - ? icons - : icons.stream().filter(icon -> containsString(icon.getDescription(), filterString)).toList(); + ? icons + : icons.stream().filter(icon -> containsString(icon.getDescription(), filterString)).toList(); var data = partitionList(displayedIcons, colNum); getItems().setAll(data); diff --git a/sampler/src/main/java/atlantafx/sampler/page/general/IconsPage.java b/sampler/src/main/java/atlantafx/sampler/page/general/IconsPage.java index 9544e35..f16e525 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/general/IconsPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/general/IconsPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.general; import static atlantafx.sampler.page.SampleBlock.BLOCK_HGAP; @@ -32,7 +33,9 @@ public class IconsPage extends AbstractPage { public static final String NAME = "Icons"; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } public IconsPage() { super(); @@ -41,15 +44,15 @@ public class IconsPage extends AbstractPage { private void createView() { var headerText = new TextFlow( - new Text("AtlantaFX supports "), - hyperlink("Ikonli", URI.create("https://kordamp.org/ikonli")), - new Text(" iconic fonts that can be used together with some JavaFX components.") + new Text("AtlantaFX supports "), + hyperlink("Ikonli", URI.create("https://kordamp.org/ikonli")), + new Text(" iconic fonts that can be used together with some JavaFX components.") ); var browserText = new TextFlow( - new Text("There's a variety of icon packs. Sampler app uses "), - hyperlink("Material Icons", URI.create("https://kordamp.org/ikonli/cheat-sheet-material2.html")), - new Text(" you can preview below.") + new Text("There's a variety of icon packs. Sampler app uses "), + hyperlink("Material Icons", URI.create("https://kordamp.org/ikonli/cheat-sheet-material2.html")), + new Text(" you can preview below.") ); var filterText = new CustomTextField(); @@ -68,12 +71,12 @@ public class IconsPage extends AbstractPage { iconBrowser.filterProperty().bind(filterText.textProperty()); setUserContent(new VBox( - PAGE_VGAP, - headerText, - expandingHBox(colorSample(), stackingSample()), - browserText, - filterBox, - iconBrowser + PAGE_VGAP, + headerText, + expandingHBox(colorSample(), stackingSample()), + browserText, + filterBox, + iconBrowser )); } @@ -91,9 +94,9 @@ public class IconsPage extends AbstractPage { dangerIcon.getStyleClass().add(Styles.DANGER); var content = new VBox( - BLOCK_VGAP, - new Label("You can also use pseudo-classes to set icon color."), - new HBox(BLOCK_HGAP, accentIcon, successIcon, warningIcon, dangerIcon) + BLOCK_VGAP, + new Label("You can also use pseudo-classes to set icon color."), + new HBox(BLOCK_HGAP, accentIcon, successIcon, warningIcon, dangerIcon) ); return new SampleBlock("Colors", content); @@ -109,14 +112,14 @@ public class IconsPage extends AbstractPage { var stackIcon1 = new StackedFontIcon(); stackIcon1.getChildren().addAll(innerIcon1, outerIcon1); new CSSFragment(""" - .stacked-ikonli-font-icon > .outer-icon { - -fx-icon-size: 48px; - -fx-icon-color: -color-danger-emphasis; - } - .stacked-ikonli-font-icon > .inner-icon { - -fx-icon-size: 24px; - } - """).addTo(stackIcon1); + .stacked-ikonli-font-icon > .outer-icon { + -fx-icon-size: 48px; + -fx-icon-color: -color-danger-emphasis; + } + .stacked-ikonli-font-icon > .inner-icon { + -fx-icon-size: 24px; + } + """).addTo(stackIcon1); var outerIcon2 = new FontIcon(Material2OutlinedAL.CHECK_BOX_OUTLINE_BLANK); outerIcon2.getStyleClass().add("outer-icon"); @@ -127,13 +130,13 @@ public class IconsPage extends AbstractPage { var stackIcon2 = new StackedFontIcon(); stackIcon2.getChildren().addAll(outerIcon2, innerIcon2); new CSSFragment(""" - .stacked-ikonli-font-icon > .outer-icon { - -fx-icon-size: 48px; - } - .stacked-ikonli-font-icon > .inner-icon { - -fx-icon-size: 24px; - } - """).addTo(stackIcon2); + .stacked-ikonli-font-icon > .outer-icon { + -fx-icon-size: 48px; + } + .stacked-ikonli-font-icon > .inner-icon { + -fx-icon-size: 24px; + } + """).addTo(stackIcon2); var content = new HBox(BLOCK_HGAP, stackIcon1, stackIcon2); diff --git a/sampler/src/main/java/atlantafx/sampler/page/general/ThemePage.java b/sampler/src/main/java/atlantafx/sampler/page/general/ThemePage.java index dac301a..3d4d734 100755 --- a/sampler/src/main/java/atlantafx/sampler/page/general/ThemePage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/general/ThemePage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.general; import static atlantafx.sampler.event.ThemeEvent.EventType.COLOR_CHANGE; @@ -42,10 +43,10 @@ public class ThemePage extends AbstractPage { private final Consumer colorBlockActionHandler = colorBlock -> { ContrastCheckerDialog dialog = getOrCreateContrastCheckerDialog(); dialog.getContent().setValues( - colorBlock.getFgColorName(), - colorBlock.getFgColor(), - colorBlock.getBgColorName(), - colorBlock.getBgColor() + colorBlock.getFgColorName(), + colorBlock.getFgColor(), + colorBlock.getBgColorName(), + colorBlock.getBgColor() ); overlay.setContent(dialog, HPos.CENTER); overlay.toFront(); @@ -59,13 +60,19 @@ public class ThemePage extends AbstractPage { private ContrastCheckerDialog contrastCheckerDialog; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } @Override - public boolean canDisplaySourceCode() { return false; } + public boolean canDisplaySourceCode() { + return false; + } @Override - public boolean canChangeThemeSettings() { return false; } + public boolean canChangeThemeSettings() { + return false; + } public ThemePage() { super(); @@ -93,17 +100,18 @@ public class ThemePage extends AbstractPage { private void createView() { var noteText = new TextFlow( - new Text("AtlantaFX follows "), - hyperlink("Github Primer interface guidelines", URI.create("https://primer.style/design/foundations/color")), - new Text(" and color system.") + new Text("AtlantaFX follows "), + hyperlink("Github Primer interface guidelines", + URI.create("https://primer.style/design/foundations/color")), + new Text(" and color system.") ); setUserContent(new VBox( - Page.PAGE_VGAP, - createOptionsGrid(), - noteText, - colorPalette, - colorScale + Page.PAGE_VGAP, + createOptionsGrid(), + noteText, + colorPalette, + colorScale )); selectCurrentTheme(); @@ -141,7 +149,9 @@ public class ThemePage extends AbstractPage { var selector = new ChoiceBox(); selector.getItems().setAll(TM.getRepository().getAll()); selector.getSelectionModel().selectedItemProperty().addListener((obs, old, val) -> { - if (val != null && getScene() != null) { TM.setTheme(val); } + if (val != null && getScene() != null) { + TM.setTheme(val); + } }); selector.setPrefWidth(250); @@ -154,9 +164,9 @@ public class ThemePage extends AbstractPage { @Override public SamplerTheme fromString(String themeName) { return TM.getRepository().getAll().stream() - .filter(t -> Objects.equals(themeName, t.getName())) - .findFirst() - .orElse(null); + .filter(t -> Objects.equals(themeName, t.getName())) + .findFirst() + .orElse(null); } }); @@ -164,11 +174,13 @@ public class ThemePage extends AbstractPage { } private void selectCurrentTheme() { - if (TM.getTheme() == null) { return; } + if (TM.getTheme() == null) { + return; + } themeSelector.getItems().stream() - .filter(t -> Objects.equals(TM.getTheme().getName(), t.getName())) - .findFirst() - .ifPresent(t -> themeSelector.getSelectionModel().select(t)); + .filter(t -> Objects.equals(TM.getTheme().getName(), t.getName())) + .findFirst() + .ifPresent(t -> themeSelector.getSelectionModel().select(t)); } private ThemeRepoManagerDialog getOrCreateThemeRepoManagerDialog() { diff --git a/sampler/src/main/java/atlantafx/sampler/page/general/ThemeRepoManager.java b/sampler/src/main/java/atlantafx/sampler/page/general/ThemeRepoManager.java index cb4134b..e9d1440 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/general/ThemeRepoManager.java +++ b/sampler/src/main/java/atlantafx/sampler/page/general/ThemeRepoManager.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.general; import static atlantafx.base.theme.Styles.BUTTON_CIRCLE; @@ -75,7 +76,9 @@ class ThemeRepoManager extends VBox { public void update() { themeList.getChildren().forEach(c -> { - if (c instanceof ThemeCell cell) { cell.update(); } + if (c instanceof ThemeCell cell) { + cell.update(); + } }); } @@ -159,10 +162,10 @@ class ThemeRepoManager extends VBox { previewBox.getStyleClass().add("preview"); previewBox.setStyle(style.toString()); previewBox.getChildren().setAll( - previewLabel("A", "-color-bg-default", "-color-fg-default"), - previewLabel("B", "-color-accent-emphasis", "-color-fg-emphasis"), - previewLabel("C", "-color-success-emphasis", "-color-fg-emphasis"), - previewLabel("D", "-color-danger-emphasis", "-color-fg-emphasis") + previewLabel("A", "-color-bg-default", "-color-fg-default"), + previewLabel("B", "-color-accent-emphasis", "-color-fg-emphasis"), + previewLabel("C", "-color-success-emphasis", "-color-fg-emphasis"), + previewLabel("D", "-color-danger-emphasis", "-color-fg-emphasis") ); getChildren().set(2, previewBox); @@ -171,7 +174,8 @@ class ThemeRepoManager extends VBox { }); task.setOnFailed( - e -> System.err.println("[ERROR] Unable to parse \"" + theme.getName() + "\" theme colors. Either CSS not valid or file isn't readable.") + e -> System.err.println("[ERROR] Unable to parse \"" + theme.getName() + + "\" theme colors. Either CSS not valid or file isn't readable.") ); THREAD_POOL.execute(task); @@ -181,7 +185,9 @@ class ThemeRepoManager extends VBox { deleteBtn = new Button("", new FontIcon(Material2OutlinedAL.DELETE)); deleteBtn.getStyleClass().addAll(BUTTON_ICON, BUTTON_CIRCLE, FLAT, DANGER); deleteBtn.setOnAction(e -> { - if (deleteHandler != null) { deleteHandler.accept(theme); } + if (deleteHandler != null) { + deleteHandler.accept(theme); + } }); var controlsBox = new HBox(); diff --git a/sampler/src/main/java/atlantafx/sampler/page/general/ThemeRepoManagerDialog.java b/sampler/src/main/java/atlantafx/sampler/page/general/ThemeRepoManagerDialog.java index e5b92ed..3038e18 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/general/ThemeRepoManagerDialog.java +++ b/sampler/src/main/java/atlantafx/sampler/page/general/ThemeRepoManagerDialog.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.general; import atlantafx.base.theme.Styles; @@ -26,7 +27,9 @@ class ThemeRepoManagerDialog extends OverlayDialog { var fileChooser = new FileChooser(); fileChooser.getExtensionFilters().addAll(new ExtensionFilter("CSS (*.css)", "*.css")); File file = fileChooser.showOpenDialog(getScene().getWindow()); - if (file != null) { repoManager.addFromFile(file); } + if (file != null) { + repoManager.addFromFile(file); + } }); footerBox.getChildren().add(0, addBtn); diff --git a/sampler/src/main/java/atlantafx/sampler/page/general/TypographyPage.java b/sampler/src/main/java/atlantafx/sampler/page/general/TypographyPage.java index 45a511d..4ed6b7e 100755 --- a/sampler/src/main/java/atlantafx/sampler/page/general/TypographyPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/general/TypographyPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.general; import static atlantafx.base.theme.Styles.ACCENT; @@ -66,13 +67,19 @@ public class TypographyPage extends AbstractPage { private Pane fontSizeSampleContent; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } @Override - public boolean canDisplaySourceCode() { return false; } + public boolean canDisplaySourceCode() { + return false; + } @Override - public boolean canChangeThemeSettings() { return false; } + public boolean canChangeThemeSettings() { + return false; + } public TypographyPage() { super(); @@ -98,12 +105,12 @@ public class TypographyPage extends AbstractPage { fontSizeSampleContent = (Pane) fontSizeSample.getContent(); setUserContent(new VBox( - PAGE_VGAP, - controlsGrid, - fontSizeSample, - fontWeightSample(), - expandingHBox(fontStyleSample(), textColorSample(), hyperlinkSample()), - textFlowSample() + PAGE_VGAP, + controlsGrid, + fontSizeSample, + fontWeightSample(), + expandingHBox(fontStyleSample(), textColorSample(), hyperlinkSample()), + textFlowSample() )); } @@ -131,9 +138,9 @@ public class TypographyPage extends AbstractPage { private Spinner crateFontSizeSpinner() { var spinner = new Spinner( - SUPPORTED_FONT_SIZE.get(0), - SUPPORTED_FONT_SIZE.get(SUPPORTED_FONT_SIZE.size() - 1), - TM.getFontSize() + SUPPORTED_FONT_SIZE.get(0), + SUPPORTED_FONT_SIZE.get(SUPPORTED_FONT_SIZE.size() - 1), + TM.getFontSize() ); spinner.getStyleClass().add(Spinner.STYLE_CLASS_SPLIT_ARROWS_HORIZONTAL); spinner.setPrefWidth(CONTROL_WIDTH); @@ -159,10 +166,10 @@ public class TypographyPage extends AbstractPage { var t = new Timeline(new KeyFrame(delay)); t.setOnFinished(e -> { Map map = fontSizeSampleContent.getChildren().stream() - .collect(Collectors.toMap( - n -> GridPane.getColumnIndex(n).toString() + GridPane.getRowIndex(n).toString(), - n -> n - )); + .collect(Collectors.toMap( + n -> GridPane.getColumnIndex(n).toString() + GridPane.getRowIndex(n).toString(), + n -> n + )); ((Label) map.get("10")).setText(String.format("%.0fpx", getFontSize(map.get("00")))); ((Label) map.get("11")).setText(String.format("%.0fpx", getFontSize(map.get("01")))); ((Label) map.get("12")).setText(String.format("%.0fpx", getFontSize(map.get("02")))); @@ -206,60 +213,61 @@ public class TypographyPage extends AbstractPage { private SampleBlock fontWeightSample() { var sample1 = new HBox( - BLOCK_HGAP, - createText("Bold", TEXT_BOLD), - createText("Bolder", TEXT_BOLDER), - createText("Normal", TEXT_NORMAL), - createText("Lighter", TEXT_LIGHTER) + BLOCK_HGAP, + createText("Bold", TEXT_BOLD), + createText("Bolder", TEXT_BOLDER), + createText("Normal", TEXT_NORMAL), + createText("Lighter", TEXT_LIGHTER) ); sample1.setAlignment(Pos.BASELINE_LEFT); var sample2 = new HBox( - BLOCK_HGAP, - createStyledText("900", "-fx-font-weight:900;"), - createStyledText("800", "-fx-font-weight:800;"), - createStyledText("700", "-fx-font-weight:700;"), - createStyledText("600", "-fx-font-weight:600;"), - createStyledText("500", "-fx-font-weight:500;"), - createStyledText("400", "-fx-font-weight:400;"), - createStyledText("300", "-fx-font-weight:300;"), - createStyledText("200", "-fx-font-weight:200;"), - createStyledText("100", "-fx-font-weight:100;") + BLOCK_HGAP, + createStyledText("900", "-fx-font-weight:900;"), + createStyledText("800", "-fx-font-weight:800;"), + createStyledText("700", "-fx-font-weight:700;"), + createStyledText("600", "-fx-font-weight:600;"), + createStyledText("500", "-fx-font-weight:500;"), + createStyledText("400", "-fx-font-weight:400;"), + createStyledText("300", "-fx-font-weight:300;"), + createStyledText("200", "-fx-font-weight:200;"), + createStyledText("100", "-fx-font-weight:100;") ); sample2.setAlignment(Pos.BASELINE_LEFT); var sample3 = new HBox( - BLOCK_HGAP, - createStyledText("900", "-fx-font-family:'Inter Black';"), - createStyledText("800", "-fx-font-family:'Inter Extra Bold';"), - createStyledText("700", "-fx-font-family:'Inter Bold';"), - createStyledText("600", "-fx-font-family:'Inter Semi Bold';"), - createStyledText("500", "-fx-font-family:'Inter Medium';"), - createStyledText("400", "-fx-font-family:'Inter Regular';"), - createStyledText("300", "-fx-font-family:'Inter Light';"), - createStyledText("200", "-fx-font-family:'Inter Extra Light';"), - createStyledText("100", "-fx-font-family:'Inter Thin';") + BLOCK_HGAP, + createStyledText("900", "-fx-font-family:'Inter Black';"), + createStyledText("800", "-fx-font-family:'Inter Extra Bold';"), + createStyledText("700", "-fx-font-family:'Inter Bold';"), + createStyledText("600", "-fx-font-family:'Inter Semi Bold';"), + createStyledText("500", "-fx-font-family:'Inter Medium';"), + createStyledText("400", "-fx-font-family:'Inter Regular';"), + createStyledText("300", "-fx-font-family:'Inter Light';"), + createStyledText("200", "-fx-font-family:'Inter Extra Light';"), + createStyledText("100", "-fx-font-family:'Inter Thin';") ); sample3.setAlignment(Pos.BASELINE_LEFT); // JDK-8090423: https://bugs.openjdk.org/browse/JDK-8090423 // Workaround: https://edencoding.com/resources/css_properties/fx-font-weight/ return new SampleBlock("Font Weight", new VBox( - BLOCK_VGAP, - sample1, - sample2, - sample3, - createText("JavaFX only supports Bold or Regular font weight. See the source code for workaround.", TEXT, WARNING) + BLOCK_VGAP, + sample1, + sample2, + sample3, + createText("JavaFX only supports Bold or Regular font weight. See the source code for workaround.", TEXT, + WARNING) )); } private SampleBlock fontStyleSample() { var box = new FlowPane( - BLOCK_HGAP, BLOCK_VGAP, - createText("Italic", TEXT_ITALIC), - createText("Oblique", TEXT_OBLIQUE), - createText("Underlined", TEXT_UNDERLINED), - createText("Strikethrough", TEXT_STRIKETHROUGH) + BLOCK_HGAP, BLOCK_VGAP, + createText("Italic", TEXT_ITALIC), + createText("Oblique", TEXT_OBLIQUE), + createText("Underlined", TEXT_UNDERLINED), + createText("Strikethrough", TEXT_STRIKETHROUGH) ); box.setAlignment(Pos.BASELINE_LEFT); @@ -268,13 +276,13 @@ public class TypographyPage extends AbstractPage { private SampleBlock textColorSample() { var box = new FlowPane( - BLOCK_HGAP, BLOCK_VGAP, - createText("Accent", TEXT, ACCENT), - createText("Success", TEXT, SUCCESS), - createText("Warning", TEXT, WARNING), - createText("Danger", TEXT, DANGER), - createText("Muted", TEXT, TEXT_MUTED), - createText("Subtle", TEXT, TEXT_SUBTLE) + BLOCK_HGAP, BLOCK_VGAP, + createText("Accent", TEXT, ACCENT), + createText("Success", TEXT, SUCCESS), + createText("Warning", TEXT, WARNING), + createText("Danger", TEXT, DANGER), + createText("Muted", TEXT, TEXT_MUTED), + createText("Subtle", TEXT, TEXT_SUBTLE) ); box.setAlignment(Pos.BASELINE_LEFT); @@ -293,11 +301,11 @@ public class TypographyPage extends AbstractPage { linkBroken.setMnemonicParsing(true); var box = new FlowPane( - BLOCK_HGAP, BLOCK_VGAP, - linkNormal, - linkVisited, - linkBroken, - createHyperlink("Disabled", false, true) + BLOCK_HGAP, BLOCK_VGAP, + linkNormal, + linkVisited, + linkBroken, + createHyperlink("Disabled", false, true) ); box.setAlignment(Pos.BASELINE_LEFT); @@ -306,18 +314,19 @@ public class TypographyPage extends AbstractPage { private SampleBlock textFlowSample() { var textFlow = new TextFlow( - new Text("Lorem ipsum dolor sit amet, consectetur adipiscing elit. "), - new Hyperlink("Vivamus at lorem"), - new Text(" in urna facilisis aliquam. Morbi ut "), - new Hyperlink("velit"), - new Text(" iaculis erat cursus molestie eget laoreet quam. "), - new Text(" Vivamus eu nulla sapien. Sed et malesuada augue. Nullam nec "), - new Hyperlink("consectetur"), - new Text(" "), - new Hyperlink("ipsum"), - new Text(", eget facilisis enim. Suspendisse potenti. Nulla euismod, nisl sed dapibus pretium, augue ligula finibus arcu, in iaculis nulla neque a est. Sed in rutrum diam. Donec quis arcu molestie, facilisis ex fringilla, "), - new Hyperlink("volutpat velit"), - new Text(".") + new Text("Lorem ipsum dolor sit amet, consectetur adipiscing elit. "), + new Hyperlink("Vivamus at lorem"), + new Text(" in urna facilisis aliquam. Morbi ut "), + new Hyperlink("velit"), + new Text(" iaculis erat cursus molestie eget laoreet quam. "), + new Text(" Vivamus eu nulla sapien. Sed et malesuada augue. Nullam nec "), + new Hyperlink("consectetur"), + new Text(" "), + new Hyperlink("ipsum"), + new Text( + ", eget facilisis enim. Suspendisse potenti. Nulla euismod, nisl sed dapibus pretium, augue ligula finibus arcu, in iaculis nulla neque a est. Sed in rutrum diam. Donec quis arcu molestie, facilisis ex fringilla, "), + new Hyperlink("volutpat velit"), + new Text(".") ); return new SampleBlock("Text Flow", textFlow); diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/Bookmark.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/Bookmark.java index 9cde81f..c0e9d8c 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/Bookmark.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/Bookmark.java @@ -1,7 +1,9 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.filemanager; import java.nio.file.Path; import org.kordamp.ikonli.Ikon; -record Bookmark(String title, Path path, Ikon icon) { } +record Bookmark(String title, Path path, Ikon icon) { +} diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/BookmarkList.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/BookmarkList.java index caf1ca1..3baab57 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/BookmarkList.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/BookmarkList.java @@ -18,12 +18,12 @@ final class BookmarkList extends ListView { // this is Linux specific and only for EN locale getItems().setAll( - new Bookmark("Home", USER_HOME, Feather.HOME), - new Bookmark("Documents", USER_HOME.resolve("Documents"), Feather.FILE), - new Bookmark("Downloads", USER_HOME.resolve("Downloads"), Feather.DOWNLOAD), - new Bookmark("Music", USER_HOME.resolve("Music"), Feather.MUSIC), - new Bookmark("Pictures", USER_HOME.resolve("Pictures"), Feather.IMAGE), - new Bookmark("Videos", USER_HOME.resolve("Videos"), Feather.VIDEO) + new Bookmark("Home", USER_HOME, Feather.HOME), + new Bookmark("Documents", USER_HOME.resolve("Documents"), Feather.FILE), + new Bookmark("Downloads", USER_HOME.resolve("Downloads"), Feather.DOWNLOAD), + new Bookmark("Music", USER_HOME.resolve("Music"), Feather.MUSIC), + new Bookmark("Pictures", USER_HOME.resolve("Pictures"), Feather.IMAGE), + new Bookmark("Videos", USER_HOME.resolve("Videos"), Feather.VIDEO) ); setCellFactory(param -> { diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/DirectoryView.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/DirectoryView.java index 9233e84..08e10e4 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/DirectoryView.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/DirectoryView.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.filemanager; import java.nio.file.Path; diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/FileIconRepository.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/FileIconRepository.java index eaa5cb5..5484a56 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/FileIconRepository.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/FileIconRepository.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.filemanager; import atlantafx.sampler.Resources; @@ -11,17 +12,23 @@ import javafx.scene.image.Image; final class FileIconRepository { private static final String IMAGE_DIRECTORY = "images/papirus/"; - public static final Image UNKNOWN_FILE = new Image(Resources.getResourceAsStream(IMAGE_DIRECTORY + "mimetypes/text-plain.png")); - public static final Image FOLDER = new Image(Resources.getResourceAsStream(IMAGE_DIRECTORY + "places/folder-blue.png")); + public static final Image UNKNOWN_FILE = + new Image(Resources.getResourceAsStream(IMAGE_DIRECTORY + "mimetypes/text-plain.png")); + public static final Image FOLDER = + new Image(Resources.getResourceAsStream(IMAGE_DIRECTORY + "places/folder-blue.png")); private final Map cache = new HashMap<>(); private final Set unknownMimeTypes = new HashSet<>(); public Image getByMimeType(String mimeType) { - if (mimeType == null || unknownMimeTypes.contains(mimeType)) { return UNKNOWN_FILE; } + if (mimeType == null || unknownMimeTypes.contains(mimeType)) { + return UNKNOWN_FILE; + } var cachedImage = cache.get(mimeType); - if (cachedImage != null) { return cachedImage; } + if (cachedImage != null) { + return cachedImage; + } var fileName = mimeType.replaceAll("/", "-") + ".png"; diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/FileList.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/FileList.java index 96ad0d2..f032320 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/FileList.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/FileList.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.filemanager; import static atlantafx.sampler.page.showcase.filemanager.Utils.isFileHidden; @@ -21,7 +22,7 @@ import javafx.scene.control.TableView; final class FileList { static final Comparator FILE_TYPE_COMPARATOR = - Comparator.comparing(path -> !Files.isDirectory(path)); + Comparator.comparing(path -> !Files.isDirectory(path)); static final Predicate PREDICATE_ANY = path -> true; static final Predicate PREDICATE_NOT_HIDDEN = path -> !isFileHidden(path); @@ -36,8 +37,8 @@ final class FileList { sortedList.comparatorProperty().bind(Bindings.createObjectBinding(() -> { Comparator tableComparator = table.comparatorProperty().get(); return tableComparator != null ? - FILE_TYPE_COMPARATOR.thenComparing(tableComparator) : - FILE_TYPE_COMPARATOR; + FILE_TYPE_COMPARATOR.thenComparing(tableComparator) : + FILE_TYPE_COMPARATOR; }, table.comparatorProperty())); table.setItems(sortedList); } diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/FileManagerPage.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/FileManagerPage.java index 03e90d3..aacadfc 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/FileManagerPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/FileManagerPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.filemanager; import static atlantafx.base.theme.Styles.BUTTON_ICON; @@ -48,10 +49,12 @@ public class FileManagerPage extends ShowcasePage { public static final String NAME = "File Manager"; private static final String STYLESHEET_URL = - Objects.requireNonNull(FileManagerPage.class.getResource("file-manager.css")).toExternalForm(); + Objects.requireNonNull(FileManagerPage.class.getResource("file-manager.css")).toExternalForm(); @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } private final Model model = new Model(); @@ -77,8 +80,8 @@ public class FileManagerPage extends ShowcasePage { var createMenuBtn = new MenuButton(); createMenuBtn.setText("New"); createMenuBtn.getItems().setAll( - new MenuItem("New Folder"), - new MenuItem("New Document") + new MenuItem("New Folder"), + new MenuItem("New Document") ); var toggleHiddenCheck = new CheckMenuItem("Show Hidden Files"); @@ -90,13 +93,13 @@ public class FileManagerPage extends ShowcasePage { menuBtn.getStyleClass().addAll(BUTTON_ICON, Tweaks.NO_ARROW); topBar.getItems().setAll( - backBtn, - forthBtn, - new Spacer(10), - breadcrumbs, - new Spacer(), - createMenuBtn, - menuBtn + backBtn, + forthBtn, + new Spacer(10), + breadcrumbs, + new Spacer(), + createMenuBtn, + menuBtn ); // ~ @@ -117,17 +120,18 @@ public class FileManagerPage extends ShowcasePage { var splitPane = new SplitPane(bookmarksList, directoryView.getView()); splitPane.widthProperty().addListener( - // set sidebar width in pixels depending on split pane width - (obs, old, val) -> splitPane.setDividerPosition(0, 200 / splitPane.getWidth()) + // set sidebar width in pixels depending on split pane width + (obs, old, val) -> splitPane.setDividerPosition(0, 200 / splitPane.getWidth()) ); - var aboutBox = new HBox(new Text("Simple file manager. You can traverse through the file system and open files via default system application.")); + var aboutBox = new HBox(new Text( + "Simple file manager. You can traverse through the file system and open files via default system application.")); aboutBox.setPadding(new Insets(5, 0, 5, 0)); aboutBox.getStyleClass().add("about"); var creditsBox = new HBox(5, - new Text("Inspired by ©"), - hyperlink("Gnome Files", URI.create("https://gitlab.gnome.org/GNOME/nautilus")) + new Text("Inspired by ©"), + hyperlink("Gnome Files", URI.create("https://gitlab.gnome.org/GNOME/nautilus")) ); creditsBox.getStyleClass().add("credits"); creditsBox.setAlignment(Pos.CENTER_RIGHT); @@ -141,8 +145,8 @@ public class FileManagerPage extends ShowcasePage { root.setBottom(creditsBox); toggleHiddenCheck.selectedProperty().addListener((obs, old, val) -> directoryView.getFileList() - .predicateProperty() - .set(val ? PREDICATE_ANY : PREDICATE_NOT_HIDDEN) + .predicateProperty() + .set(val ? PREDICATE_ANY : PREDICATE_NOT_HIDDEN) ); directoryView.getFileList().predicateProperty().set(PREDICATE_NOT_HIDDEN); @@ -154,7 +158,7 @@ public class FileManagerPage extends ShowcasePage { // crumb count should be calculated depending on available width breadcrumbs.setSelectedCrumb( - Breadcrumbs.buildTreeModel(getParentPath(val, 4).toArray(Path[]::new)) + Breadcrumbs.buildTreeModel(getParentPath(val, 4).toArray(Path[]::new)) ); directoryView.setDirectory(val); }); @@ -172,14 +176,14 @@ public class FileManagerPage extends ShowcasePage { }; Callback, ? extends Node> dividerFactory = item -> - item != null && !item.isLast() ? new Label("", new FontIcon(Material2AL.CHEVRON_RIGHT)) : null; + item != null && !item.isLast() ? new Label("", new FontIcon(Material2AL.CHEVRON_RIGHT)) : null; var breadcrumbs = new Breadcrumbs(); breadcrumbs.setAutoNavigationEnabled(false); breadcrumbs.setCrumbFactory(crumbFactory); breadcrumbs.setDividerFactory(dividerFactory); breadcrumbs.setSelectedCrumb(Breadcrumbs.buildTreeModel( - getParentPath(model.currentPathProperty().get(), 4).toArray(Path[]::new)) + getParentPath(model.currentPathProperty().get(), 4).toArray(Path[]::new)) ); return breadcrumbs; diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/Model.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/Model.java index 13cd036..b6ff2a4 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/Model.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/Model.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.filemanager; import java.nio.file.Path; @@ -23,9 +24,13 @@ final class Model { // Properties // /////////////////////////////////////////////////////////////////////////// - public ReadOnlyObjectProperty currentPathProperty() { return currentPath.getReadOnlyProperty(); } + public ReadOnlyObjectProperty currentPathProperty() { + return currentPath.getReadOnlyProperty(); + } - public NavigationHistory getHistory() { return history; } + public NavigationHistory getHistory() { + return history; + } /////////////////////////////////////////////////////////////////////////// // Commands // @@ -41,6 +46,8 @@ final class Model { public void navigate(Path path, boolean saveInHistory) { currentPath.set(Objects.requireNonNullElse(path, USER_HOME)); - if (saveInHistory) { history.append(path); } + if (saveInHistory) { + history.append(path); + } } } diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/NavigationHistory.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/NavigationHistory.java index 99f0b7c..64e0425 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/NavigationHistory.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/NavigationHistory.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.filemanager; import java.nio.file.Path; @@ -16,25 +17,33 @@ final class NavigationHistory { private final IntegerProperty cursor = new SimpleIntegerProperty(0); private final List history = new ArrayList<>(); private final BooleanBinding canGoBack = Bindings.createBooleanBinding( - () -> cursor.get() > 0 && history.size() > 1, cursor); + () -> cursor.get() > 0 && history.size() > 1, cursor); private final BooleanBinding canGoForth = Bindings.createBooleanBinding( - () -> cursor.get() < history.size() - 1, cursor); + () -> cursor.get() < history.size() - 1, cursor); public void append(Path path) { - if (path == null) { return; } + if (path == null) { + return; + } var lastPath = history.size() > 0 ? history.get(history.size() - 1) : null; - if (!Objects.equals(lastPath, path)) { history.add(path); } + if (!Objects.equals(lastPath, path)) { + history.add(path); + } cursor.set(history.size() - 1); } public Optional back() { - if (!canGoBack.get()) { return Optional.empty(); } + if (!canGoBack.get()) { + return Optional.empty(); + } cursor.set(cursor.get() - 1); return Optional.of(history.get(cursor.get())); } public Optional forth() { - if (!canGoForth.get()) { return Optional.empty(); } + if (!canGoForth.get()) { + return Optional.empty(); + } cursor.set(cursor.get() + 1); return Optional.of(history.get(cursor.get())); } diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/RightClickMenu.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/RightClickMenu.java index 1659de9..2ce4027 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/RightClickMenu.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/RightClickMenu.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.filemanager; import static javafx.scene.input.KeyCombination.CONTROL_DOWN; @@ -33,15 +34,15 @@ final class RightClickMenu extends ContextMenu { var properties = new MenuItem("Properties"); getItems().setAll( - open, - new SeparatorMenuItem(), - cut, - copy, - rename, - new SeparatorMenuItem(), - compress, - new SeparatorMenuItem(), - properties + open, + new SeparatorMenuItem(), + cut, + copy, + rename, + new SeparatorMenuItem(), + compress, + new SeparatorMenuItem(), + properties ); } } diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/TableDirectoryView.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/TableDirectoryView.java index 5e15408..284514e 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/TableDirectoryView.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/TableDirectoryView.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.filemanager; import static atlantafx.sampler.page.showcase.filemanager.Utils.fileMTime; @@ -55,7 +56,7 @@ final class TableDirectoryView extends AnchorPane implements DirectoryView { private TableView createTable() { var filenameCol = new TableColumn("Name"); filenameCol.setCellValueFactory(param -> new SimpleStringProperty( - param.getValue() != null ? param.getValue().getFileName().toString() : null + param.getValue() != null ? param.getValue().getFileName().toString() : null )); filenameCol.setComparator(Comparator.comparing(String::toLowerCase)); filenameCol.setSortType(ASCENDING); @@ -195,8 +196,8 @@ final class TableDirectoryView extends AnchorPane implements DirectoryView { setText(null); } else { setText(fileTime != null ? - HumanReadableFormat.date(fileTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime()) : - UNKNOWN + HumanReadableFormat.date(fileTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDateTime()) : + UNKNOWN ); } } diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/Utils.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/Utils.java index cbc1d4a..676dd46 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/Utils.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/filemanager/Utils.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.filemanager; import java.awt.Desktop; diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/ColorThief.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/ColorThief.java index 02ad42a..c16c9ff 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/ColorThief.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/ColorThief.java @@ -7,6 +7,7 @@ * Creative Commons Attribution 2.5 License: * http://creativecommons.org/licenses/by/2.5/ */ + package atlantafx.sampler.page.showcase.musicplayer; import static java.awt.image.BufferedImage.TYPE_3BYTE_BGR; @@ -28,13 +29,17 @@ final class ColorThief { public static int[] getColor(BufferedImage source) { int[][] palette = getPalette(source, 5); - if (palette == null) { return null; } + if (palette == null) { + return null; + } return palette[0]; } public static int[][] getPalette(BufferedImage source, int colorCount) { MMCQ.ColorMap colorMap = getColorMap(source, colorCount); - if (colorMap == null) { return null; } + if (colorMap == null) { + return null; + } return colorMap.palette(); } @@ -60,9 +65,9 @@ final class ColorThief { } private static int[][] getPixelsFast( - BufferedImage sourceImage, - int quality, - boolean ignoreWhite) { + BufferedImage sourceImage, + int quality, + boolean ignoreWhite) { DataBufferByte imageData = (DataBufferByte) sourceImage.getRaster().getDataBuffer(); byte[] pixels = imageData.getData(); int pixelCount = sourceImage.getWidth() * sourceImage.getHeight(); @@ -78,7 +83,7 @@ final class ColorThief { int expectedDataLength = pixelCount * colorDepth; if (expectedDataLength != pixels.length) { throw new IllegalArgumentException( - "(expectedDataLength = " + expectedDataLength + ") != (pixels.length = " + pixels.length + ")" + "(expectedDataLength = " + expectedDataLength + ") != (pixels.length = " + pixels.length + ")" ); } @@ -97,7 +102,7 @@ final class ColorThief { r = pixels[offset + 2] & 0xFF; if (!(ignoreWhite && r > 250 && g > 250 && b > 250)) { - pixelArray[numUsedPixels] = new int[] { r, g, b }; + pixelArray[numUsedPixels] = new int[] {r, g, b}; numUsedPixels++; } } @@ -112,7 +117,7 @@ final class ColorThief { r = pixels[offset + 3] & 0xFF; if (a >= 125 && !(ignoreWhite && r > 250 && g > 250 && b > 250)) { - pixelArray[numUsedPixels] = new int[] { r, g, b }; + pixelArray[numUsedPixels] = new int[] {r, g, b}; numUsedPixels++; } } @@ -126,9 +131,9 @@ final class ColorThief { } private static int[][] getPixelsSlow( - BufferedImage sourceImage, - int quality, - boolean ignoreWhite) { + BufferedImage sourceImage, + int quality, + boolean ignoreWhite) { int width = sourceImage.getWidth(); int height = sourceImage.getHeight(); @@ -148,7 +153,7 @@ final class ColorThief { g = (rgb >> 8) & 0xFF; b = rgb & 0xFF; if (!(ignoreWhite && r > 250 && g > 250 && b > 250)) { - res[numUsedPixels] = new int[] { r, g, b }; + res[numUsedPixels] = new int[] {r, g, b}; numUsedPixels++; } } @@ -254,9 +259,10 @@ final class ColorThief { } if (ntot > 0) { - _avg = new int[] { (rsum / ntot), (gsum / ntot), (bsum / ntot) }; + _avg = new int[] {(rsum / ntot), (gsum / ntot), (bsum / ntot)}; } else { - _avg = new int[] { (MULT * (r1 + r2 + 1) / 2), (MULT * (g1 + g2 + 1) / 2), (MULT * (b1 + b2 + 1) / 2) }; + _avg = new int[] {(MULT * (r1 + r2 + 1) / 2), (MULT * (g1 + g2 + 1) / 2), + (MULT * (b1 + b2 + 1) / 2)}; } } @@ -311,8 +317,8 @@ final class ColorThief { for (VBox vbox : vboxes) { int[] vbColor = vbox.avg(false); d2 = Math.sqrt(Math.pow(color[0] - vbColor[0], 2) + - Math.pow(color[1] - vbColor[1], 2) + - Math.pow(color[2] - vbColor[2], 2) + Math.pow(color[1] - vbColor[1], 2) + + Math.pow(color[2] - vbColor[2], 2) ); if (d2 < d1) { d1 = d2; @@ -380,7 +386,7 @@ final class ColorThief { } if (vbox.count(false) == 1) { - return new VBox[] { vbox.clone(), null }; + return new VBox[] {vbox.clone(), null}; } int rw = vbox.r2 - vbox.r1 + 1; @@ -440,16 +446,16 @@ final class ColorThief { } return maxw == rw ? doCut('r', vbox, partialSum, lookAheadSum, total) - : maxw == gw ? doCut('g', vbox, partialSum, lookAheadSum, total) - : doCut('b', vbox, partialSum, lookAheadSum, total); + : maxw == gw ? doCut('g', vbox, partialSum, lookAheadSum, total) + : doCut('b', vbox, partialSum, lookAheadSum, total); } private static VBox[] doCut( - char color, - VBox vbox, - int[] partialSum, - int[] lookAheadSum, - int total + char color, + VBox vbox, + int[] partialSum, + int[] lookAheadSum, + int total ) { int vbox_dim1; int vbox_dim2; @@ -502,7 +508,7 @@ final class ColorThief { vbox2.b1 = d2 + 1; } - return new VBox[] { vbox1, vbox2 }; + return new VBox[] {vbox1, vbox2}; } } @@ -510,7 +516,9 @@ final class ColorThief { } public static ColorMap quantize(int[][] pixels, int maxcolors) { - if (pixels.length == 0 || maxcolors < 2 || maxcolors > 256) { return null; } + if (pixels.length == 0 || maxcolors < 2 || maxcolors > 256) { + return null; + } int[] histo = getHisto(pixels); @@ -568,7 +576,9 @@ final class ColorThief { if (lh.size() >= target) { return; } - if (niters++ > MAX_ITERATIONS) { return; } + if (niters++ > MAX_ITERATIONS) { + return; + } } } @@ -580,7 +590,9 @@ final class ColorThief { int aVolume = a.volume(false); int bVolume = b.volume(false); - if (aCount == bCount) { return aVolume - bVolume; } + if (aCount == bCount) { + return aVolume - bVolume; + } return Long.compare((long) aCount * aVolume, (long) bCount * bVolume); }; diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/MediaFile.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/MediaFile.java index 7d3cab2..252e63d 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/MediaFile.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/MediaFile.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.musicplayer; import static atlantafx.sampler.page.showcase.musicplayer.MediaFile.Metadata.NO_ALBUM; @@ -37,11 +38,11 @@ record MediaFile(File file) { var image = getTag(metadata, "image", Image.class, null); // clone everything to make sure media player will be garbage collected return new Metadata( - new String(getTag(metadata, "title", String.class, NO_TITLE)), - image != null ? copyImage(image) : null, - new String(getTag(metadata, "artist", String.class, NO_ARTIST)), - new String(getTag(metadata, "album", String.class, NO_ALBUM)), - media.getDuration().toMillis() + new String(getTag(metadata, "title", String.class, NO_TITLE)), + image != null ? copyImage(image) : null, + new String(getTag(metadata, "artist", String.class, NO_ARTIST)), + new String(getTag(metadata, "album", String.class, NO_ALBUM)), + media.getDuration().toMillis() ); })); @@ -63,11 +64,11 @@ record MediaFile(File file) { record Metadata(String title, Image image, String artist, String album, double duration) { static final Image NO_IMAGE = new Image( - Resources.getResourceAsStream("images/no-image.png"), 150, 150, true, false + Resources.getResourceAsStream("images/no-image.png"), 150, 150, true, false ); static final Image NO_IMAGE_ALT = new Image( - Resources.getResourceAsStream("images/papirus/mimetypes/audio-mp3.png"), 150, 150, true, false + Resources.getResourceAsStream("images/papirus/mimetypes/audio-mp3.png"), 150, 150, true, false ); static final String NO_TITLE = "Unknown title"; diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/Model.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/Model.java index ca9e31e..dfc8928 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/Model.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/Model.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.musicplayer; import java.util.Objects; @@ -21,14 +22,16 @@ final class Model { public Model() { canGoBack.bind(Bindings.createBooleanBinding( - () -> playlist.size() > 1 && getPlaylistPosition() > 0, currentTrack) + () -> playlist.size() > 1 && getPlaylistPosition() > 0, currentTrack) ); canGoForward.bind(Bindings.createBooleanBinding( - () -> playlist.size() > 0 && getPlaylistPosition() < playlist.size() - 1, currentTrack)); + () -> playlist.size() > 0 && getPlaylistPosition() < playlist.size() - 1, currentTrack)); } private int getPlaylistPosition() { - if (currentTrack.get() == null) { return -1; } + if (currentTrack.get() == null) { + return -1; + } return playlist.indexOf(currentTrack.get()); } @@ -36,15 +39,25 @@ final class Model { // Properties // /////////////////////////////////////////////////////////////////////////// - public ObservableList playlist() { return playlist; } + public ObservableList playlist() { + return playlist; + } - public ReadOnlyBooleanProperty canGoBackProperty() { return canGoBack.getReadOnlyProperty(); } + public ReadOnlyBooleanProperty canGoBackProperty() { + return canGoBack.getReadOnlyProperty(); + } - public ReadOnlyBooleanProperty canGoForwardProperty() { return canGoForward.getReadOnlyProperty(); } + public ReadOnlyBooleanProperty canGoForwardProperty() { + return canGoForward.getReadOnlyProperty(); + } - public ReadOnlyObjectProperty currentTrackProperty() { return currentTrack.getReadOnlyProperty(); } + public ReadOnlyObjectProperty currentTrackProperty() { + return currentTrack.getReadOnlyProperty(); + } - public ReadOnlyObjectProperty backgroundColorProperty() { return backgroundColor.getReadOnlyProperty(); } + public ReadOnlyObjectProperty backgroundColorProperty() { + return backgroundColor.getReadOnlyProperty(); + } /////////////////////////////////////////////////////////////////////////// // Commands // @@ -55,11 +68,15 @@ final class Model { } public void playPrevious() { - if (canGoBack.get()) { currentTrack.set(playlist.get(getPlaylistPosition() - 1)); } + if (canGoBack.get()) { + currentTrack.set(playlist.get(getPlaylistPosition() - 1)); + } } public void playNext() { - if (canGoForward.get()) { currentTrack.set(playlist.get(getPlaylistPosition() + 1)); } + if (canGoForward.get()) { + currentTrack.set(playlist.get(getPlaylistPosition() + 1)); + } } public void reset() { diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/MusicPlayerPage.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/MusicPlayerPage.java index a508def..f966ece 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/MusicPlayerPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/MusicPlayerPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.musicplayer; import static atlantafx.sampler.util.Controls.hyperlink; @@ -20,10 +21,12 @@ public class MusicPlayerPage extends ShowcasePage { public static final double BACKGROUND_OPACITY = 0.2; public static final Set SUPPORTED_MEDIA_TYPES = Set.of("mp3"); private static final String STYLESHEET_URL = Objects.requireNonNull( - MusicPlayerPage.class.getResource("music-player.css")).toExternalForm(); + MusicPlayerPage.class.getResource("music-player.css")).toExternalForm(); @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } private final Model model = new Model(); @@ -41,8 +44,8 @@ public class MusicPlayerPage extends ShowcasePage { aboutBox.getStyleClass().add("about"); var creditsBox = new HBox(5, - new Text("Inspired by ©"), - hyperlink("Amberol", URI.create("https://gitlab.gnome.org/World/amberol")) + new Text("Inspired by ©"), + hyperlink("Amberol", URI.create("https://gitlab.gnome.org/World/amberol")) ); creditsBox.getStyleClass().add("credits"); creditsBox.setAlignment(Pos.CENTER_RIGHT); diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/PlayerPane.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/PlayerPane.java index f2545d3..378a348 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/PlayerPane.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/PlayerPane.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.musicplayer; import static atlantafx.base.controls.Popover.ArrowLocation; @@ -183,12 +184,16 @@ final class PlayerPane extends VBox { setAlignment(CENTER); setSpacing(5); setMinWidth(300); - getChildren().setAll(new Spacer(VERTICAL), new StackPane(coverImage), new Spacer(10, VERTICAL), trackTitle, trackArtist, trackAlbum, new Spacer(20, VERTICAL), mediaControls, new Spacer(10, VERTICAL), timeSlider, timeMarkersBox, new Spacer(10, VERTICAL), extraControls, new Spacer(VERTICAL)); + getChildren().setAll(new Spacer(VERTICAL), new StackPane(coverImage), new Spacer(10, VERTICAL), trackTitle, + trackArtist, trackAlbum, new Spacer(20, VERTICAL), mediaControls, new Spacer(10, VERTICAL), timeSlider, + timeMarkersBox, new Spacer(10, VERTICAL), extraControls, new Spacer(VERTICAL)); } private void init() { heightProperty().addListener((obs, old, val) -> { - if (val == null) { return; } + if (val == null) { + return; + } int size = val.intValue() < 600 ? 150 : 250; coverImage.setWidth(size); coverImage.setHeight(size); @@ -196,26 +201,35 @@ final class PlayerPane extends VBox { playBtn.setOnAction(e -> { MediaPlayer player = currentPlayer.get(); - if (player == null) { return; } + if (player == null) { + return; + } switch (player.getStatus()) { case READY, PAUSED, STOPPED -> player.play(); case PLAYING -> player.pause(); - default -> { } + default -> { + } } }); InvalidationListener mediaTimeChangeListener = obs -> { - if (currentPlayer.get() == null) { return; } + if (currentPlayer.get() == null) { + return; + } var duration = currentPlayer.get().getCurrentTime(); var seconds = duration != null && !duration.equals(Duration.ZERO) ? duration.toSeconds() : 0; - if (!timeSlider.isValueChanging()) { timeSlider.setValue(seconds); } + if (!timeSlider.isValueChanging()) { + timeSlider.setValue(seconds); + } currentTimeLabel.setText(seconds > 0 ? formatDuration(duration) : "0.0"); }; timeSlider.valueProperty().addListener(obs -> { - if (currentPlayer.get() == null) { return; } + if (currentPlayer.get() == null) { + return; + } long max = (long) currentPlayer.get().getMedia().getDuration().toSeconds(); long sliderVal = (long) timeSlider.getValue(); if (sliderVal <= max && timeSlider.isValueChanging()) { @@ -249,7 +263,9 @@ final class PlayerPane extends VBox { endTimeLabel.setText(formatDuration(media.getDuration())); playIcon.iconCodeProperty().bind(Bindings.createObjectBinding(() -> { - if (mediaPlayer.statusProperty().get() == null) { return EQUALS; } + if (mediaPlayer.statusProperty().get() == null) { + return EQUALS; + } return switch (mediaPlayer.getStatus()) { case READY, PAUSED, STOPPED -> PLAY_ARROW; case PLAYING -> PAUSE; @@ -279,7 +295,9 @@ final class PlayerPane extends VBox { } private T getTag(Media media, String key, Class type, T defaultValue) { - if (media == null || key == null || type == null) { return defaultValue; } + if (media == null || key == null || type == null) { + return defaultValue; + } Object tag = media.getMetadata().get(key); return type.isInstance(tag) ? type.cast(tag) : defaultValue; } diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/PlayerScreen.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/PlayerScreen.java index be3b793..854eeef 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/PlayerScreen.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/PlayerScreen.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.musicplayer; import static atlantafx.sampler.util.JColorUtils.toHexWithAlpha; @@ -28,22 +29,22 @@ final class PlayerScreen extends SplitPane { model.backgroundColorProperty().addListener((obs, old, val) -> { var domColor = Objects.equals(Color.TRANSPARENT, val) ? - Color.TRANSPARENT : - Color.color(val.getRed(), val.getGreen(), val.getBlue(), 1); + Color.TRANSPARENT : + Color.color(val.getRed(), val.getGreen(), val.getBlue(), 1); var domColor20 = Objects.equals(Color.TRANSPARENT, val) ? - Color.TRANSPARENT : - Color.color(val.getRed(), val.getGreen(), val.getBlue(), 0.2); + Color.TRANSPARENT : + Color.color(val.getRed(), val.getGreen(), val.getBlue(), 0.2); var domColor50 = Objects.equals(Color.TRANSPARENT, val) ? - Color.TRANSPARENT : - Color.color(val.getRed(), val.getGreen(), val.getBlue(), 0.5); + Color.TRANSPARENT : + Color.color(val.getRed(), val.getGreen(), val.getBlue(), 0.5); var domColor70 = Objects.equals(Color.TRANSPARENT, val) ? - Color.TRANSPARENT : - Color.color(val.getRed(), val.getGreen(), val.getBlue(), 0.7); + Color.TRANSPARENT : + Color.color(val.getRed(), val.getGreen(), val.getBlue(), 0.7); setStyle("-color-dominant:" + toHexWithAlpha(domColor) + ";" + - "-color-dominant-20:" + toHexWithAlpha(domColor20) + ";" + - "-color-dominant-50:" + toHexWithAlpha(domColor50) + ";" + - "-color-dominant-70:" + toHexWithAlpha(domColor70) + ";" + - "-color-dominant-border:" + toHexWithAlpha(domColor70) + ";" + "-color-dominant-20:" + toHexWithAlpha(domColor20) + ";" + + "-color-dominant-50:" + toHexWithAlpha(domColor50) + ";" + + "-color-dominant-70:" + toHexWithAlpha(domColor70) + ";" + + "-color-dominant-border:" + toHexWithAlpha(domColor70) + ";" ); }); } diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/PlaylistPane.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/PlaylistPane.java index 5dacbee..e926bde 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/PlaylistPane.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/PlaylistPane.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.musicplayer; import static atlantafx.base.theme.Styles.FLAT; @@ -82,9 +83,9 @@ final class PlaylistPane extends VBox { controlsBox.setPadding(new Insets(0, 0, 10, 0)); controlsBox.getStyleClass().add("controls"); controlsBox.getChildren().setAll( - new VBox(5, headerLabel, sizeDescLabel), - new Spacer(), - addButton + new VBox(5, headerLabel, sizeDescLabel), + new Spacer(), + addButton ); controlsBox.setAlignment(CENTER_LEFT); @@ -118,11 +119,13 @@ final class PlaylistPane extends VBox { var extensions = SUPPORTED_MEDIA_TYPES.stream().map(s -> "*." + s).toList(); var fileChooser = new FileChooser(); fileChooser.getExtensionFilters().addAll(new ExtensionFilter( - "MP3 files (" + String.join(", ", extensions) + ")", - extensions + "MP3 files (" + String.join(", ", extensions) + ")", + extensions )); List files = fileChooser.showOpenMultipleDialog(getScene().getWindow()); - if (files == null || files.isEmpty()) { return; } + if (files == null || files.isEmpty()) { + return; + } loadProgress.setVisible(true); final Task task = new Task<>() { @@ -182,7 +185,9 @@ final class PlaylistPane extends VBox { root = new HBox(10, coverImage, titleBox, playMark); root.setAlignment(CENTER_LEFT); root.setOnMouseClicked(e -> { - if (getItem() != null) { model.play(getItem()); } + if (getItem() != null) { + model.play(getItem()); + } }); } @@ -205,7 +210,7 @@ final class PlaylistPane extends VBox { mediaFile.readMetadata(metadata -> { coverImage.setFill(new ImagePattern( - metadata.image() != null ? metadata.image() : NO_IMAGE_ALT + metadata.image() != null ? metadata.image() : NO_IMAGE_ALT )); titleLabel.setText(metadata.title()); artistLabel.setText(metadata.artist()); diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/StartScreen.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/StartScreen.java index ed92b8c..b9c2fe3 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/StartScreen.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/StartScreen.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.musicplayer; import static atlantafx.sampler.page.showcase.musicplayer.MusicPlayerPage.SUPPORTED_MEDIA_TYPES; @@ -39,7 +40,7 @@ final class StartScreen extends BorderPane { var jumboIcon = new FontIcon(Feather.MUSIC); var noteText = new TextFlow(new Text( - "Select a file or a folder." + "Select a file or a folder." )); noteText.setMaxWidth(400); noteText.setTextAlignment(TextAlignment.CENTER); @@ -71,11 +72,13 @@ final class StartScreen extends BorderPane { var extensions = SUPPORTED_MEDIA_TYPES.stream().map(s -> "*." + s).toList(); var fileChooser = new FileChooser(); fileChooser.getExtensionFilters().addAll(new ExtensionFilter( - "MP3 files (" + String.join(", ", extensions) + ")", - extensions + "MP3 files (" + String.join(", ", extensions) + ")", + extensions )); List files = fileChooser.showOpenMultipleDialog(getScene().getWindow()); - if (files == null || files.isEmpty()) { return; } + if (files == null || files.isEmpty()) { + return; + } for (File file : files) { model.addFile(new MediaFile(file)); @@ -85,15 +88,21 @@ final class StartScreen extends BorderPane { private void addFolder() { DirectoryChooser directoryChooser = new DirectoryChooser(); File dir = directoryChooser.showDialog(getScene().getWindow()); - if (dir == null) { return; } + if (dir == null) { + return; + } var path = dir.toPath(); - if (!Files.isDirectory(path) || !Files.isReadable(path)) { return; } + if (!Files.isDirectory(path) || !Files.isReadable(path)) { + return; + } try (Stream stream = Files.list(path)) { stream.forEach(p -> { for (String s : SUPPORTED_MEDIA_TYPES) { - if (!p.toAbsolutePath().toString().endsWith(s)) { continue; } + if (!p.toAbsolutePath().toString().endsWith(s)) { + continue; + } model.addFile(new MediaFile(p.toFile())); } }); diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/Utils.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/Utils.java index e671fd9..464ddd3 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/Utils.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/musicplayer/Utils.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.musicplayer; import javafx.embed.swing.SwingFXUtils; @@ -27,14 +28,16 @@ final class Utils { public static Color getDominantColor(Image image, double opacity) { int[] dominant = ColorThief.getColor(SwingFXUtils.fromFXImage(image, null)); - if (dominant == null || dominant.length != 3) { return Color.TRANSPARENT; } + if (dominant == null || dominant.length != 3) { + return Color.TRANSPARENT; + } return Color.rgb(dominant[0], dominant[1], dominant[2], opacity); } public static String formatDuration(Duration duration) { long seconds = (long) duration.toSeconds(); return seconds < 3600 ? - String.format("%02d:%02d", (seconds % 3600) / 60, seconds % 60) : - String.format("%d:%02d:%02d", seconds / 3600, (seconds % 3600) / 60, seconds % 60); + String.format("%02d:%02d", (seconds % 3600) / 60, seconds % 60) : + String.format("%d:%02d:%02d", seconds / 3600, (seconds % 3600) / 60, seconds % 60); } } diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/Card.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/Card.java index 0bbf61d..615ee0f 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/Card.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/Card.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.widget; import atlantafx.base.theme.Styles; @@ -18,19 +19,19 @@ import javafx.scene.layout.VBox; public class Card extends VBox { public static final String CSS = """ - .card { - -fx-background-color: -color-bg-default; - } - .card > .subtitle { - -fx-text-fill: -color-fg-muted; - -fx-padding: 0px 15px 10px 15px; - } - .card > .title, - .card > .body, - .card > .footer { - -fx-padding: 10px 15px 10px 15px; - } - """; + .card { + -fx-background-color: -color-bg-default; + } + .card > .subtitle { + -fx-text-fill: -color-fg-muted; + -fx-padding: 0px 15px 10px 15px; + } + .card > .title, + .card > .body, + .card > .footer { + -fx-padding: 10px 15px 10px 15px; + } + """; private final StringProperty title = new SimpleStringProperty(); private final StringProperty subtitle = new SimpleStringProperty(); @@ -47,32 +48,32 @@ public class Card extends VBox { var footerSep = new Separator(); footerSep.getStyleClass().add(Styles.SMALL); footerSep.managedProperty().bind(Bindings.createObjectBinding( - () -> footer.get() != null && footer.get().isManaged(), footer + () -> footer.get() != null && footer.get().isManaged(), footer )); getChildren().setAll( - createPlaceholder(), // title - createPlaceholder(), // subtitle - createPlaceholder(), // image - createPlaceholder(), // body - footerSep, - createPlaceholder() // footer + createPlaceholder(), // title + createPlaceholder(), // subtitle + createPlaceholder(), // image + createPlaceholder(), // body + footerSep, + createPlaceholder() // footer ); image.addListener( - (obs, old, val) -> setChild(0, val, "image") + (obs, old, val) -> setChild(0, val, "image") ); title.addListener( - (obs, old, val) -> setChild(1, val != null ? new Label(val) : null, "title", Styles.TITLE_4) + (obs, old, val) -> setChild(1, val != null ? new Label(val) : null, "title", Styles.TITLE_4) ); subtitle.addListener( - (obs, old, val) -> setChild(2, val != null ? new Label(val) : null, "subtitle") + (obs, old, val) -> setChild(2, val != null ? new Label(val) : null, "subtitle") ); body.addListener( - (obs, old, val) -> setChild(3, val, "body") + (obs, old, val) -> setChild(3, val, "body") ); footer.addListener( - (obs, old, val) -> setChild(5, val, "footer") + (obs, old, val) -> setChild(5, val, "footer") ); getStyleClass().addAll("card", Styles.BORDERED); diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/CardSample.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/CardSample.java index 9e197b5..13de738 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/CardSample.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/CardSample.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.widget; import static atlantafx.sampler.page.Page.PAGE_HGAP; @@ -36,20 +37,20 @@ public class CardSample extends HBox { setAlignment(Pos.TOP_CENTER); setMinWidth(CARD_WIDTH * 2 + PAGE_HGAP); getChildren().setAll( - // column 0 - new VBox( - PAGE_VGAP, - textFooterCard(), - titleTextCard(), - quoteCard() - ), - // column 1 - new VBox( - PAGE_VGAP, - imageTextCard(), - titleImageCard(), - statisticCard() - ) + // column 0 + new VBox( + PAGE_VGAP, + textFooterCard(), + titleTextCard(), + quoteCard() + ), + // column 1 + new VBox( + PAGE_VGAP, + imageTextCard(), + titleImageCard(), + statisticCard() + ) ); } @@ -134,14 +135,14 @@ public class CardSample extends HBox { var authorText = new Text("Bojack Horseman"); card.setBody(new VBox( - 10, - new TextFlow(quoteText), - authorText + 10, + new TextFlow(quoteText), + authorText )); card.setFooter(new TextFlow( - new Text("Share on "), - new Hyperlink("Twitter") + new Text("Share on "), + new Hyperlink("Twitter") )); return card; diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/Message.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/Message.java index a526a96..10fd999 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/Message.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/Message.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.widget; import atlantafx.base.theme.Styles; @@ -25,41 +26,41 @@ public class Message extends StackPane { } public static final String CSS = """ - .message { - -color-message-bg: -color-bg-default; - -color-message-fg: -color-fg-default; - -fx-background-color: -color-message-bg; - -fx-border-color: -color-message-fg; - -fx-border-width: 0 0 0 5px; - -fx-pref-width: 600px; - -fx-alignment: TOP_LEFT; - } - .message > .header { - -fx-font-weight: bold; - } - .message Text { - -fx-fill: -color-message-fg; - } - .message > .button { - -color-button-fg: -color-message-fg; - } - .message.info { - -color-message-bg: -color-accent-subtle; - -color-message-fg: -color-accent-fg; - } - .message.success { - -color-message-bg: -color-success-subtle; - -color-message-fg: -color-success-fg; - } - .message.warning { - -color-message-bg: -color-warning-subtle; - -color-message-fg: -color-warning-fg; - } - .message.danger { - -color-message-bg: -color-danger-subtle; - -color-message-fg: -color-danger-fg; - } - """; + .message { + -color-message-bg: -color-bg-default; + -color-message-fg: -color-fg-default; + -fx-background-color: -color-message-bg; + -fx-border-color: -color-message-fg; + -fx-border-width: 0 0 0 5px; + -fx-pref-width: 600px; + -fx-alignment: TOP_LEFT; + } + .message > .header { + -fx-font-weight: bold; + } + .message Text { + -fx-fill: -color-message-fg; + } + .message > .button { + -color-button-fg: -color-message-fg; + } + .message.info { + -color-message-bg: -color-accent-subtle; + -color-message-fg: -color-accent-fg; + } + .message.success { + -color-message-bg: -color-success-subtle; + -color-message-fg: -color-success-fg; + } + .message.warning { + -color-message-bg: -color-warning-subtle; + -color-message-fg: -color-warning-fg; + } + .message.danger { + -color-message-bg: -color-danger-subtle; + -color-message-fg: -color-danger-fg; + } + """; private final Type type; private final String header; @@ -98,7 +99,9 @@ public class Message extends StackPane { getChildren().add(closeBtn); parentProperty().addListener((obs, old, val) -> { - if (val != null) { handleOpen(); } + if (val != null) { + handleOpen(); + } }); getStyleClass().setAll("message", type.name().toLowerCase()); diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/MessageSample.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/MessageSample.java index 27596dd..8c7f237 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/MessageSample.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/MessageSample.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.widget; import atlantafx.sampler.page.SampleBlock; diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/Stepper.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/Stepper.java index 2fc7ea2..6a40668 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/Stepper.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/Stepper.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.widget; import java.util.ArrayList; @@ -26,51 +27,51 @@ import org.kordamp.ikonli.javafx.FontIcon; public class Stepper extends HBox { public static final String CSS = """ - .stepper { - -color-stepper-bg: -color-bg-subtle; - -color-stepper-fg: -color-fg-default; - -color-stepper-border: -color-border-default; - -fx-pref-width: 600px; - -fx-spacing: 10px; - } - .stepper > .item { - -fx-graphic-text-gap: 10px; - } - .stepper > .item > .graphic { - -fx-font-size: 1.1em; - -fx-min-width: 2.2em; - -fx-max-width: 2.2em; - -fx-min-height: 2.2em; - -fx-max-height: 2.2em; - -fx-text-fill: -color-stepper-fg; - -fx-background-color: -color-stepper-bg; - -fx-background-radius: 10em; - -fx-border-color: -color-stepper-border; - -fx-border-radius: 10em; - -fx-border-width: 1; - -fx-alignment: CENTER; - } - .stepper > .item .ikonli-font-icon { - -fx-fill: -color-stepper-fg; - -fx-icon-color: -color-stepper-fg; - } - .stepper > .item:selected { - -color-stepper-bg: -color-bg-default; - -color-stepper-fg: -color-accent-fg; - -color-stepper-border: -color-accent-emphasis; - } - .stepper > .item:selected > .graphic { - -color-stepper-bg: -color-bg-default; - -color-stepper-fg: -color-accent-fg; - -color-stepper-border: -color-accent-emphasis; - -fx-border-width: 2; - } - .stepper > .item:completed { - -color-stepper-bg: -color-accent-emphasis; - -color-stepper-fg: -color-fg-emphasis; - -color-stepper-border: -color-accent-emphasis; - } - """; + .stepper { + -color-stepper-bg: -color-bg-subtle; + -color-stepper-fg: -color-fg-default; + -color-stepper-border: -color-border-default; + -fx-pref-width: 600px; + -fx-spacing: 10px; + } + .stepper > .item { + -fx-graphic-text-gap: 10px; + } + .stepper > .item > .graphic { + -fx-font-size: 1.1em; + -fx-min-width: 2.2em; + -fx-max-width: 2.2em; + -fx-min-height: 2.2em; + -fx-max-height: 2.2em; + -fx-text-fill: -color-stepper-fg; + -fx-background-color: -color-stepper-bg; + -fx-background-radius: 10em; + -fx-border-color: -color-stepper-border; + -fx-border-radius: 10em; + -fx-border-width: 1; + -fx-alignment: CENTER; + } + .stepper > .item .ikonli-font-icon { + -fx-fill: -color-stepper-fg; + -fx-icon-color: -color-stepper-fg; + } + .stepper > .item:selected { + -color-stepper-bg: -color-bg-default; + -color-stepper-fg: -color-accent-fg; + -color-stepper-border: -color-accent-emphasis; + } + .stepper > .item:selected > .graphic { + -color-stepper-bg: -color-bg-default; + -color-stepper-fg: -color-accent-fg; + -color-stepper-border: -color-accent-emphasis; + -fx-border-width: 2; + } + .stepper > .item:completed { + -color-stepper-bg: -color-accent-emphasis; + -color-stepper-fg: -color-fg-emphasis; + -color-stepper-border: -color-accent-emphasis; + } + """; private static final PseudoClass SELECTED = PseudoClass.getPseudoClass("selected"); private static final PseudoClass COMPLETED = PseudoClass.getPseudoClass("completed"); @@ -93,20 +94,28 @@ public class Stepper extends HBox { this.items = Collections.unmodifiableList(items); canGoBack = Bindings.createBooleanBinding(() -> { - if (selectedItem.get() == null) { return false; } + if (selectedItem.get() == null) { + return false; + } var idx = items.indexOf(selectedItem.get()); return idx > 0 && idx <= items.size() - 1; }, selectedItem); canGoForward = Bindings.createBooleanBinding(() -> { - if (selectedItem.get() == null) { return false; } + if (selectedItem.get() == null) { + return false; + } var idx = items.indexOf(selectedItem.get()); return idx >= 0 && idx < items.size() - 1; }, selectedItem); selectedItem.addListener((obs, old, val) -> { - if (old != null) { old.pseudoClassStateChanged(SELECTED, false); } - if (val != null) { val.pseudoClassStateChanged(SELECTED, true); } + if (old != null) { + old.pseudoClassStateChanged(SELECTED, false); + } + if (val != null) { + val.pseudoClassStateChanged(SELECTED, true); + } }); createView(); @@ -114,11 +123,11 @@ public class Stepper extends HBox { private void createView() { alignmentProperty().bind(Bindings.createObjectBinding(() -> - switch (textPositionProperty().get()) { - case TOP -> Pos.TOP_LEFT; - case BOTTOM -> Pos.BOTTOM_LEFT; - default -> Pos.CENTER_LEFT; - }, textPositionProperty()) + switch (textPositionProperty().get()) { + case TOP -> Pos.TOP_LEFT; + case BOTTOM -> Pos.BOTTOM_LEFT; + default -> Pos.CENTER_LEFT; + }, textPositionProperty()) ); updateItems(); @@ -130,12 +139,12 @@ public class Stepper extends HBox { for (int i = 0; i < items.size(); i++) { var item = items.get(i); item.contentDisplayProperty().bind(Bindings.createObjectBinding(() -> - switch (textPositionProperty().get()) { - case TOP -> ContentDisplay.TOP; - case BOTTOM -> ContentDisplay.BOTTOM; - case LEFT -> ContentDisplay.LEFT; - case RIGHT -> ContentDisplay.RIGHT; - }, textPositionProperty()) + switch (textPositionProperty().get()) { + case TOP -> ContentDisplay.TOP; + case BOTTOM -> ContentDisplay.BOTTOM; + case LEFT -> ContentDisplay.LEFT; + case RIGHT -> ContentDisplay.RIGHT; + }, textPositionProperty()) ); children.add(item); @@ -182,7 +191,9 @@ public class Stepper extends HBox { } public void backward() { - if (!canGoBack.get()) { return; } + if (!canGoBack.get()) { + return; + } var idx = items.indexOf(selectedItem.get()); selectedItem.set(items.get(idx - 1)); } @@ -192,7 +203,9 @@ public class Stepper extends HBox { } public void forward() { - if (!canGoForward.get()) { return; } + if (!canGoForward.get()) { + return; + } var idx = items.indexOf(selectedItem.get()); selectedItem.set(items.get(idx + 1)); } diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/StepperSample.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/StepperSample.java index 6ba07d2..1e6205c 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/StepperSample.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/StepperSample.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.widget; import atlantafx.base.controls.Spacer; @@ -56,7 +57,7 @@ public class StepperSample extends SampleBlock { var stepper = new Stepper(firstItem, secondItem, thirdItem); stepper.selectedItemProperty().addListener( - (obs, old, val) -> stackContent.setText(val != null ? val.getText() : null) + (obs, old, val) -> stackContent.setText(val != null ? val.getText() : null) ); stepper.setSelectedItem(stepper.getItems().get(0)); @@ -70,7 +71,7 @@ public class StepperSample extends SampleBlock { stepper.forward(); }); nextBtn.textProperty().bind(Bindings.createStringBinding( - () -> stepper.canGoForwardProperty().get() ? "Next" : "Done", stepper.canGoForwardProperty()) + () -> stepper.canGoForwardProperty().get() ? "Next" : "Done", stepper.canGoForwardProperty()) ); var prevBtn = new Button("Previous"); @@ -105,12 +106,12 @@ public class StepperSample extends SampleBlock { }); var controls = new HBox( - BLOCK_HGAP, - nextBtn, - prevBtn, - new Spacer(), - iconToggle, - rotateBtn + BLOCK_HGAP, + nextBtn, + prevBtn, + new Spacer(), + iconToggle, + rotateBtn ); controls.setAlignment(Pos.CENTER_LEFT); diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/Tag.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/Tag.java index b785398..7b0d0fb 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/Tag.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/Tag.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.widget; import static javafx.scene.control.ContentDisplay.RIGHT; @@ -10,14 +11,14 @@ import javafx.scene.layout.Pane; public class Tag extends Button { public static final String CSS = """ - .tag { - -fx-padding: 4px 6px 4px 6px; - -fx-cursor: hand; - -color-button-border-hover: -color-button-border; - -color-button-border-focused: -color-button-border; - -color-button-border-pressed: -color-button-border; - } - """; + .tag { + -fx-padding: 4px 6px 4px 6px; + -fx-cursor: hand; + -color-button-border-hover: -color-button-border; + -color-button-border-focused: -color-button-border; + -color-button-border-pressed: -color-button-border; + } + """; public Tag(String text) { this(text, null); diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/TagSample.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/TagSample.java index 46bcd05..9e46dd8 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/TagSample.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/TagSample.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.widget; import static atlantafx.sampler.page.Page.PAGE_HGAP; @@ -120,24 +121,24 @@ public class TagSample extends GridPane { var content = new FlowPane(BLOCK_HGAP, BLOCK_VGAP); content.setPrefWidth(PREF_WIDTH); new CSSFragment(""" - .brand { - -color-button-fg: -color-fg-emphasis; - -color-button-bg-hover: -color-button-bg; - -color-button-bg-pressed: -color-button-bg; - } - .twitter { - -color-button-bg: rgb(85, 172, 238); - -color-button-border: rgb(85, 172, 238); - } - .youtube { - -color-button-bg: rgb(205, 32, 31); - -color-button-border: rgb(205, 32, 31); - } - .facebook { - -color-button-bg: rgb(59, 89, 153); - -color-button-border: rgb(59, 89, 153); - } - """).addTo(content); + .brand { + -color-button-fg: -color-fg-emphasis; + -color-button-bg-hover: -color-button-bg; + -color-button-bg-pressed: -color-button-bg; + } + .twitter { + -color-button-bg: rgb(85, 172, 238); + -color-button-border: rgb(85, 172, 238); + } + .youtube { + -color-button-bg: rgb(205, 32, 31); + -color-button-border: rgb(205, 32, 31); + } + .facebook { + -color-button-bg: rgb(59, 89, 153); + -color-button-border: rgb(59, 89, 153); + } + """).addTo(content); var twitterTag = new Tag("Twitter", new FontIcon(Feather.TWITTER)); twitterTag.getStyleClass().addAll("brand", "twitter"); diff --git a/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/WidgetCollectionPage.java b/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/WidgetCollectionPage.java index cf21fa9..2720610 100644 --- a/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/WidgetCollectionPage.java +++ b/sampler/src/main/java/atlantafx/sampler/page/showcase/widget/WidgetCollectionPage.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.page.showcase.widget; import atlantafx.base.theme.Styles; @@ -22,7 +23,9 @@ public class WidgetCollectionPage extends BorderPane implements Page { public static final String NAME = "Widgets"; @Override - public String getName() { return NAME; } + public String getName() { + return NAME; + } private final ListView toc = new ListView<>(); private final VBox widgetWrapper = new VBox(PAGE_HGAP); @@ -42,7 +45,9 @@ public class WidgetCollectionPage extends BorderPane implements Page { toc.getStyleClass().addAll("toc", Styles.DENSE, Tweaks.EDGE_TO_EDGE); toc.getItems().setAll(Example.values()); toc.getSelectionModel().selectedItemProperty().addListener((obs, old, val) -> { - if (val == null) { return; } + if (val == null) { + return; + } widgetWrapper.getChildren().setAll(val.getSupplier().get()); }); @@ -72,12 +77,15 @@ public class WidgetCollectionPage extends BorderPane implements Page { } @Override - public void reset() { } + public void reset() { + } @Override protected void layoutChildren() { super.layoutChildren(); - if (isRendered) { return; } + if (isRendered) { + return; + } isRendered = true; toc.getSelectionModel().selectFirst(); diff --git a/sampler/src/main/java/atlantafx/sampler/theme/CSSFragment.java b/sampler/src/main/java/atlantafx/sampler/theme/CSSFragment.java index 40a9484..4bd0daa 100644 --- a/sampler/src/main/java/atlantafx/sampler/theme/CSSFragment.java +++ b/sampler/src/main/java/atlantafx/sampler/theme/CSSFragment.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.theme; import static java.nio.charset.StandardCharsets.UTF_8; @@ -34,8 +35,12 @@ public final class CSSFragment { @Override public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } CSSFragment cssFragment = (CSSFragment) o; return css.equals(cssFragment.css); } diff --git a/sampler/src/main/java/atlantafx/sampler/theme/HighlightJSTheme.java b/sampler/src/main/java/atlantafx/sampler/theme/HighlightJSTheme.java index c8aafac..82daabc 100644 --- a/sampler/src/main/java/atlantafx/sampler/theme/HighlightJSTheme.java +++ b/sampler/src/main/java/atlantafx/sampler/theme/HighlightJSTheme.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.theme; public class HighlightJSTheme { @@ -26,14 +27,16 @@ public class HighlightJSTheme { } public static HighlightJSTheme githubLight() { - var css = ".hljs{color:#24292e;background:#fff}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#d73a49}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#6f42c1}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#005cc5}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#032f62}.hljs-built_in,.hljs-symbol{color:#e36209}.hljs-code,.hljs-comment,.hljs-formula{color:#6a737d}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#22863a}.hljs-subst{color:#24292e}.hljs-section{color:#005cc5;font-weight:700}.hljs-bullet{color:#735c0f}.hljs-emphasis{color:#24292e;font-style:italic}.hljs-strong{color:#24292e;font-weight:700}.hljs-addition{color:#22863a;background-color:#f0fff4}.hljs-deletion{color:#b31d28;background-color:#ffeef0}"; + var css = + ".hljs{color:#24292e;background:#fff}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#d73a49}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#6f42c1}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#005cc5}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#032f62}.hljs-built_in,.hljs-symbol{color:#e36209}.hljs-code,.hljs-comment,.hljs-formula{color:#6a737d}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#22863a}.hljs-subst{color:#24292e}.hljs-section{color:#005cc5;font-weight:700}.hljs-bullet{color:#735c0f}.hljs-emphasis{color:#24292e;font-style:italic}.hljs-strong{color:#24292e;font-weight:700}.hljs-addition{color:#22863a;background-color:#f0fff4}.hljs-deletion{color:#b31d28;background-color:#ffeef0}"; var bg = "#fff"; var fg = "#24292f"; return new HighlightJSTheme(css, bg, fg); } public static HighlightJSTheme githubDark() { - var css = ".hljs{color:#c9d1d9;background:#0d1117}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#ff7b72}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#d2a8ff}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#79c0ff}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#a5d6ff}.hljs-built_in,.hljs-symbol{color:#ffa657}.hljs-code,.hljs-comment,.hljs-formula{color:#8b949e}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#7ee787}.hljs-subst{color:#c9d1d9}.hljs-section{color:#1f6feb;font-weight:700}.hljs-bullet{color:#f2cc60}.hljs-emphasis{color:#c9d1d9;font-style:italic}.hljs-strong{color:#c9d1d9;font-weight:700}.hljs-addition{color:#aff5b4;background-color:#033a16}.hljs-deletion{color:#ffdcd7;background-color:#67060c}"; + var css = + ".hljs{color:#c9d1d9;background:#0d1117}.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-template-tag,.hljs-template-variable,.hljs-type,.hljs-variable.language_{color:#ff7b72}.hljs-title,.hljs-title.class_,.hljs-title.class_.inherited__,.hljs-title.function_{color:#d2a8ff}.hljs-attr,.hljs-attribute,.hljs-literal,.hljs-meta,.hljs-number,.hljs-operator,.hljs-selector-attr,.hljs-selector-class,.hljs-selector-id,.hljs-variable{color:#79c0ff}.hljs-meta .hljs-string,.hljs-regexp,.hljs-string{color:#a5d6ff}.hljs-built_in,.hljs-symbol{color:#ffa657}.hljs-code,.hljs-comment,.hljs-formula{color:#8b949e}.hljs-name,.hljs-quote,.hljs-selector-pseudo,.hljs-selector-tag{color:#7ee787}.hljs-subst{color:#c9d1d9}.hljs-section{color:#1f6feb;font-weight:700}.hljs-bullet{color:#f2cc60}.hljs-emphasis{color:#c9d1d9;font-style:italic}.hljs-strong{color:#c9d1d9;font-weight:700}.hljs-addition{color:#aff5b4;background-color:#033a16}.hljs-deletion{color:#ffdcd7;background-color:#67060c}"; var bg = "#0d1117"; var fg = "#f0f6fc"; return new HighlightJSTheme(css, bg, fg); @@ -42,14 +45,16 @@ public class HighlightJSTheme { public static HighlightJSTheme nordLight() { // there's no Nord light theme, // below is "stackoverflow-light" theme with changed background - var css = "*/.hljs{color:#2f3337;background:#f4f5f8}.hljs-subst{color:#2f3337}.hljs-comment{color:#656e77}.hljs-attr,.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-section,.hljs-selector-tag{color:#015692}.hljs-attribute{color:#803378}.hljs-name,.hljs-number,.hljs-quote,.hljs-selector-id,.hljs-template-tag,.hljs-type{color:#b75501}.hljs-selector-class{color:#015692}.hljs-link,.hljs-regexp,.hljs-selector-attr,.hljs-string,.hljs-symbol,.hljs-template-variable,.hljs-variable{color:#54790d}.hljs-meta,.hljs-selector-pseudo{color:#015692}.hljs-built_in,.hljs-literal,.hljs-title{color:#b75501}.hljs-bullet,.hljs-code{color:#535a60}.hljs-meta .hljs-string{color:#54790d}.hljs-deletion{color:#c02d2e}.hljs-addition{color:#2f6f44}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}"; + var css = + "*/.hljs{color:#2f3337;background:#f4f5f8}.hljs-subst{color:#2f3337}.hljs-comment{color:#656e77}.hljs-attr,.hljs-doctag,.hljs-keyword,.hljs-meta .hljs-keyword,.hljs-section,.hljs-selector-tag{color:#015692}.hljs-attribute{color:#803378}.hljs-name,.hljs-number,.hljs-quote,.hljs-selector-id,.hljs-template-tag,.hljs-type{color:#b75501}.hljs-selector-class{color:#015692}.hljs-link,.hljs-regexp,.hljs-selector-attr,.hljs-string,.hljs-symbol,.hljs-template-variable,.hljs-variable{color:#54790d}.hljs-meta,.hljs-selector-pseudo{color:#015692}.hljs-built_in,.hljs-literal,.hljs-title{color:#b75501}.hljs-bullet,.hljs-code{color:#535a60}.hljs-meta .hljs-string{color:#54790d}.hljs-deletion{color:#c02d2e}.hljs-addition{color:#2f6f44}.hljs-emphasis{font-style:italic}.hljs-strong{font-weight:700}"; var bg = "#fafafc"; var fg = "#2E3440"; return new HighlightJSTheme(css, bg, fg); } public static HighlightJSTheme nordDark() { - var css = "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{background:#2e3440}.hljs,.hljs-subst{color:#d8dee9}.hljs-selector-tag{color:#81a1c1}.hljs-selector-id{color:#8fbcbb;font-weight:700}.hljs-selector-attr,.hljs-selector-class{color:#8fbcbb}.hljs-property,.hljs-selector-pseudo{color:#88c0d0}.hljs-addition{background-color:rgba(163,190,140,.5)}.hljs-deletion{background-color:rgba(191,97,106,.5)}.hljs-built_in,.hljs-class,.hljs-type{color:#8fbcbb}.hljs-function,.hljs-function>.hljs-title,.hljs-title.hljs-function{color:#88c0d0}.hljs-keyword,.hljs-literal,.hljs-symbol{color:#81a1c1}.hljs-number{color:#b48ead}.hljs-regexp{color:#ebcb8b}.hljs-string{color:#a3be8c}.hljs-title{color:#8fbcbb}.hljs-params{color:#d8dee9}.hljs-bullet{color:#81a1c1}.hljs-code{color:#8fbcbb}.hljs-emphasis{font-style:italic}.hljs-formula{color:#8fbcbb}.hljs-strong{font-weight:700}.hljs-link:hover{text-decoration:underline}.hljs-comment,.hljs-quote{color:#4c566a}.hljs-doctag{color:#8fbcbb}.hljs-meta,.hljs-meta .hljs-keyword{color:#5e81ac}.hljs-meta .hljs-string{color:#a3be8c}.hljs-attr{color:#8fbcbb}.hljs-attribute{color:#d8dee9}.hljs-name{color:#81a1c1}.hljs-section{color:#88c0d0}.hljs-tag{color:#81a1c1}.hljs-template-variable,.hljs-variable{color:#d8dee9}.hljs-template-tag{color:#5e81ac}.language-abnf .hljs-attribute{color:#88c0d0}.language-abnf .hljs-symbol{color:#ebcb8b}.language-apache .hljs-attribute{color:#88c0d0}.language-apache .hljs-section{color:#81a1c1}.language-arduino .hljs-built_in{color:#88c0d0}.language-aspectj .hljs-meta{color:#d08770}.language-aspectj>.hljs-title{color:#88c0d0}.language-bnf .hljs-attribute{color:#8fbcbb}.language-clojure .hljs-name{color:#88c0d0}.language-clojure .hljs-symbol{color:#ebcb8b}.language-coq .hljs-built_in{color:#88c0d0}.language-cpp .hljs-meta .hljs-string{color:#8fbcbb}.language-css .hljs-built_in{color:#88c0d0}.language-css .hljs-keyword{color:#d08770}.language-diff .hljs-meta,.language-ebnf .hljs-attribute{color:#8fbcbb}.language-glsl .hljs-built_in{color:#88c0d0}.language-groovy .hljs-meta:not(:first-child),.language-haxe .hljs-meta,.language-java .hljs-meta{color:#d08770}.language-ldif .hljs-attribute{color:#8fbcbb}.language-lisp .hljs-name,.language-lua .hljs-built_in,.language-moonscript .hljs-built_in,.language-nginx .hljs-attribute{color:#88c0d0}.language-nginx .hljs-section{color:#5e81ac}.language-pf .hljs-built_in,.language-processing .hljs-built_in{color:#88c0d0}.language-scss .hljs-keyword,.language-stylus .hljs-keyword{color:#81a1c1}.language-swift .hljs-meta{color:#d08770}.language-vim .hljs-built_in{color:#88c0d0;font-style:italic}.language-yaml .hljs-meta{color:#d08770}"; + var css = + "pre code.hljs{display:block;overflow-x:auto;padding:1em}code.hljs{padding:3px 5px}.hljs{background:#2e3440}.hljs,.hljs-subst{color:#d8dee9}.hljs-selector-tag{color:#81a1c1}.hljs-selector-id{color:#8fbcbb;font-weight:700}.hljs-selector-attr,.hljs-selector-class{color:#8fbcbb}.hljs-property,.hljs-selector-pseudo{color:#88c0d0}.hljs-addition{background-color:rgba(163,190,140,.5)}.hljs-deletion{background-color:rgba(191,97,106,.5)}.hljs-built_in,.hljs-class,.hljs-type{color:#8fbcbb}.hljs-function,.hljs-function>.hljs-title,.hljs-title.hljs-function{color:#88c0d0}.hljs-keyword,.hljs-literal,.hljs-symbol{color:#81a1c1}.hljs-number{color:#b48ead}.hljs-regexp{color:#ebcb8b}.hljs-string{color:#a3be8c}.hljs-title{color:#8fbcbb}.hljs-params{color:#d8dee9}.hljs-bullet{color:#81a1c1}.hljs-code{color:#8fbcbb}.hljs-emphasis{font-style:italic}.hljs-formula{color:#8fbcbb}.hljs-strong{font-weight:700}.hljs-link:hover{text-decoration:underline}.hljs-comment,.hljs-quote{color:#4c566a}.hljs-doctag{color:#8fbcbb}.hljs-meta,.hljs-meta .hljs-keyword{color:#5e81ac}.hljs-meta .hljs-string{color:#a3be8c}.hljs-attr{color:#8fbcbb}.hljs-attribute{color:#d8dee9}.hljs-name{color:#81a1c1}.hljs-section{color:#88c0d0}.hljs-tag{color:#81a1c1}.hljs-template-variable,.hljs-variable{color:#d8dee9}.hljs-template-tag{color:#5e81ac}.language-abnf .hljs-attribute{color:#88c0d0}.language-abnf .hljs-symbol{color:#ebcb8b}.language-apache .hljs-attribute{color:#88c0d0}.language-apache .hljs-section{color:#81a1c1}.language-arduino .hljs-built_in{color:#88c0d0}.language-aspectj .hljs-meta{color:#d08770}.language-aspectj>.hljs-title{color:#88c0d0}.language-bnf .hljs-attribute{color:#8fbcbb}.language-clojure .hljs-name{color:#88c0d0}.language-clojure .hljs-symbol{color:#ebcb8b}.language-coq .hljs-built_in{color:#88c0d0}.language-cpp .hljs-meta .hljs-string{color:#8fbcbb}.language-css .hljs-built_in{color:#88c0d0}.language-css .hljs-keyword{color:#d08770}.language-diff .hljs-meta,.language-ebnf .hljs-attribute{color:#8fbcbb}.language-glsl .hljs-built_in{color:#88c0d0}.language-groovy .hljs-meta:not(:first-child),.language-haxe .hljs-meta,.language-java .hljs-meta{color:#d08770}.language-ldif .hljs-attribute{color:#8fbcbb}.language-lisp .hljs-name,.language-lua .hljs-built_in,.language-moonscript .hljs-built_in,.language-nginx .hljs-attribute{color:#88c0d0}.language-nginx .hljs-section{color:#5e81ac}.language-pf .hljs-built_in,.language-processing .hljs-built_in{color:#88c0d0}.language-scss .hljs-keyword,.language-stylus .hljs-keyword{color:#81a1c1}.language-swift .hljs-meta{color:#d08770}.language-vim .hljs-built_in{color:#88c0d0;font-style:italic}.language-yaml .hljs-meta{color:#d08770}"; var bg = "#2E3440"; var fg = "#ECEFF4"; return new HighlightJSTheme(css, bg, fg); diff --git a/sampler/src/main/java/atlantafx/sampler/theme/SamplerTheme.java b/sampler/src/main/java/atlantafx/sampler/theme/SamplerTheme.java index 23e1443..bcaacc8 100644 --- a/sampler/src/main/java/atlantafx/sampler/theme/SamplerTheme.java +++ b/sampler/src/main/java/atlantafx/sampler/theme/SamplerTheme.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.theme; import static atlantafx.sampler.Launcher.IS_DEV_MODE; @@ -57,7 +58,7 @@ public final class SamplerTheme implements Theme { private static final int PARSE_LIMIT = 250; private static final Pattern COLOR_PATTERN = - Pattern.compile("\s*?(-color-(fg|bg|accent|success|danger)-.+?):\s*?(.+?);"); + Pattern.compile("\s*?(-color-(fg|bg|accent|success|danger)-.+?):\s*?(.+?);"); private final Theme theme; @@ -110,7 +111,9 @@ public final class SamplerTheme implements Theme { private Map parseColorsForClasspath(FileResource file) throws IOException { // classpath resources are static, no need to parse project theme more than once - if (colors != null) { return colors; } + if (colors != null) { + return colors; + } try (var br = new BufferedReader(new InputStreamReader(file.getInputStream(), UTF_8))) { colors = parseColors(br); @@ -150,7 +153,9 @@ public final class SamplerTheme implements Theme { } lineCount++; - if (lineCount > PARSE_LIMIT) { break; } + if (lineCount > PARSE_LIMIT) { + break; + } } return colors; @@ -166,17 +171,22 @@ public final class SamplerTheme implements Theme { } FileResource classpathTheme = FileResource.internal(theme.getUserAgentStylesheet(), Theme.class); - if (!IS_DEV_MODE) { return classpathTheme; } + if (!IS_DEV_MODE) { + return classpathTheme; + } String filename = classpathTheme.getFilename(); try { FileResource testTheme = FileResource.internal(Resources.resolve("theme-test/" + filename), Launcher.class); - if (!testTheme.exists()) { throw new IOException(); } + if (!testTheme.exists()) { + throw new IOException(); + } return testTheme; } catch (Exception e) { var failedPath = resolve("theme-test/" + filename); - System.err.println("[WARNING] Unable to find theme file \"" + failedPath + "\". Fall back to the classpath."); + System.err.println( + "[WARNING] Unable to find theme file \"" + failedPath + "\". Fall back to the classpath."); return classpathTheme; } } diff --git a/sampler/src/main/java/atlantafx/sampler/theme/ThemeManager.java b/sampler/src/main/java/atlantafx/sampler/theme/ThemeManager.java index 0d917a7..d926eb3 100644 --- a/sampler/src/main/java/atlantafx/sampler/theme/ThemeManager.java +++ b/sampler/src/main/java/atlantafx/sampler/theme/ThemeManager.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.theme; import static atlantafx.sampler.Resources.getResource; @@ -34,10 +35,10 @@ public final class ThemeManager { static final String DUMMY_STYLESHEET = getResource("assets/styles/empty.css").toString(); static final String[] APP_STYLESHEETS = new String[] { - Resources.resolve("assets/styles/index.css") + Resources.resolve("assets/styles/index.css") }; static final Set> PROJECT_THEMES = Set.of( - PrimerLight.class, PrimerDark.class, NordLight.class, NordDark.class + PrimerLight.class, PrimerDark.class, NordLight.class, NordDark.class ); private static final PseudoClass DARK = PseudoClass.getPseudoClass("dark"); @@ -86,7 +87,9 @@ public final class ThemeManager { return getRepository().getAll().get(0); } - /** See {@link SamplerTheme}. */ + /** + * See {@link SamplerTheme}. + */ public void setTheme(SamplerTheme theme) { Objects.requireNonNull(theme); @@ -127,11 +130,11 @@ public final class ThemeManager { public void setFontSize(int size) { if (!SUPPORTED_FONT_SIZE.contains(size)) { throw new IllegalArgumentException( - String.format("Font size must in the range %d-%dpx. Actual value is %d.", - SUPPORTED_FONT_SIZE.get(0), - SUPPORTED_FONT_SIZE.get(SUPPORTED_FONT_SIZE.size() - 1), - size - )); + String.format("Font size must in the range %d-%dpx. Actual value is %d.", + SUPPORTED_FONT_SIZE.get(0), + SUPPORTED_FONT_SIZE.get(SUPPORTED_FONT_SIZE.size() - 1), + size + )); } setCustomDeclaration("-fx-font-size", size + "px"); @@ -141,8 +144,8 @@ public final class ThemeManager { var rawZoom = (int) Math.ceil((size * 1.0 / DEFAULT_FONT_SIZE) * 100); this.zoom = SUPPORTED_ZOOM.stream() - .min(Comparator.comparingInt(i -> Math.abs(i - rawZoom))) - .orElseThrow(NoSuchElementException::new); + .min(Comparator.comparingInt(i -> Math.abs(i - rawZoom))) + .orElseThrow(NoSuchElementException::new); reloadCustomCSS(); EVENT_BUS.publish(new ThemeEvent(EventType.FONT_CHANGE)); @@ -159,7 +162,7 @@ public final class ThemeManager { public void setZoom(int zoom) { if (!SUPPORTED_ZOOM.contains(zoom)) { throw new IllegalArgumentException( - String.format("Zoom value must one of %s. Actual value is %d.", SUPPORTED_ZOOM, zoom) + String.format("Zoom value must one of %s. Actual value is %d.", SUPPORTED_ZOOM, zoom) ); } @@ -214,8 +217,12 @@ public final class ThemeManager { public HighlightJSTheme getMatchingSourceCodeHighlightTheme(Theme theme) { Objects.requireNonNull(theme); - if ("Nord Light".equals(theme.getName())) { return HighlightJSTheme.nordLight(); } - if ("Nord Dark".equals(theme.getName())) { return HighlightJSTheme.nordDark(); } + if ("Nord Light".equals(theme.getName())) { + return HighlightJSTheme.nordLight(); + } + if ("Nord Dark".equals(theme.getName())) { + return HighlightJSTheme.nordDark(); + } return theme.isDarkMode() ? HighlightJSTheme.githubDark() : HighlightJSTheme.githubLight(); } @@ -242,10 +249,10 @@ public final class ThemeManager { Objects.requireNonNull(colorName); if (color != null) { setCustomDeclaration(colorName, JColor.color( - (float) color.getRed(), - (float) color.getGreen(), - (float) color.getBlue(), - (float) color.getOpacity()).getColorHexWithAlpha() + (float) color.getRed(), + (float) color.getGreen(), + (float) color.getBlue(), + (float) color.getOpacity()).getColorHexWithAlpha() ); } else { removeCustomDeclaration(colorName); @@ -282,7 +289,7 @@ public final class ThemeManager { getScene().getRoot().getStylesheets().removeIf(uri -> uri.startsWith("data:text/css")); getScene().getRoot().getStylesheets().add( - "data:text/css;base64," + Base64.getEncoder().encodeToString(css.toString().getBytes(UTF_8)) + "data:text/css;base64," + Base64.getEncoder().encodeToString(css.toString().getBytes(UTF_8)) ); getScene().getRoot().pseudoClassStateChanged(USER_CUSTOM, true); } @@ -297,7 +304,8 @@ public final class ThemeManager { // Singleton // /////////////////////////////////////////////////////////////////////////// - private ThemeManager() { } + private ThemeManager() { + } private static class InstanceHolder { diff --git a/sampler/src/main/java/atlantafx/sampler/theme/ThemeRepository.java b/sampler/src/main/java/atlantafx/sampler/theme/ThemeRepository.java index fdbc89f..4e228db 100644 --- a/sampler/src/main/java/atlantafx/sampler/theme/ThemeRepository.java +++ b/sampler/src/main/java/atlantafx/sampler/theme/ThemeRepository.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.theme; import static java.nio.file.LinkOption.NOFOLLOW_LINKS; @@ -30,10 +31,10 @@ public final class ThemeRepository { private static final Comparator THEME_COMPARATOR = Comparator.comparing(SamplerTheme::getName); private final List internalThemes = Arrays.asList( - new SamplerTheme(new PrimerLight()), - new SamplerTheme(new PrimerDark()), - new SamplerTheme(new NordLight()), - new SamplerTheme(new NordDark()) + new SamplerTheme(new PrimerLight()), + new SamplerTheme(new PrimerDark()), + new SamplerTheme(new NordLight()), + new SamplerTheme(new NordDark()) ); private final List externalThemes = new ArrayList<>(); @@ -64,13 +65,14 @@ public final class ThemeRepository { // creating GUI dialogs is hard, so we just obtain theme name from the file name :) String filename = file.getName(); String themeName = Arrays.stream(filename.replace(".css", "").split("[-_]")) - .map(s -> !s.isEmpty() ? s.substring(0, 1).toUpperCase() + s.substring(1) : "") - .collect(Collectors.joining(" ")); + .map(s -> !s.isEmpty() ? s.substring(0, 1).toUpperCase() + s.substring(1) : "") + .collect(Collectors.joining(" ")); var theme = new SamplerTheme(Theme.of(themeName, file.toString(), filename.contains("dark"))); if (!isUnique(theme)) { - throw new RuntimeException("A theme with the same name or user agent stylesheet already exists in the repository."); + throw new RuntimeException( + "A theme with the same name or user agent stylesheet already exists in the repository."); } addToPreferences(theme); @@ -91,9 +93,9 @@ public final class ThemeRepository { public boolean isFileValid(Path path) { Objects.requireNonNull(path); return !Files.isDirectory(path, NOFOLLOW_LINKS) && - Files.isRegularFile(path, NOFOLLOW_LINKS) && - Files.isReadable(path) && - path.getFileName().toString().endsWith(".css"); + Files.isRegularFile(path, NOFOLLOW_LINKS) && + Files.isReadable(path) && + path.getFileName().toString().endsWith(".css"); } public boolean isUnique(SamplerTheme theme) { @@ -114,13 +116,14 @@ public final class ThemeRepository { // cleanup broken links, e.g. if theme was added for testing // but then CSS file was removed from the filesystem if (!isFileValid(uaStylesheetPath)) { - System.err.println("[WARNING] CSS file invalid or missing: \"" + uaStylesheetPath + "\". Removing silently."); + System.err.println( + "[WARNING] CSS file invalid or missing: \"" + uaStylesheetPath + "\". Removing silently."); themePreferences.remove(themeName); continue; } externalThemes.add(new SamplerTheme( - Theme.of(themeName, uaStylesheet, uaStylesheetPath.getFileName().toString().contains("dark")) + Theme.of(themeName, uaStylesheet, uaStylesheetPath.getFileName().toString().contains("dark")) )); externalThemes.sort(THEME_COMPARATOR); } diff --git a/sampler/src/main/java/atlantafx/sampler/util/Animations.java b/sampler/src/main/java/atlantafx/sampler/util/Animations.java index 76d048e..b03cc8f 100644 --- a/sampler/src/main/java/atlantafx/sampler/util/Animations.java +++ b/sampler/src/main/java/atlantafx/sampler/util/Animations.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.util; import javafx.animation.Interpolator; @@ -14,50 +15,50 @@ public final class Animations { public static Timeline fadeIn(Node node, Duration duration) { return new Timeline( - new KeyFrame(Duration.millis(0), new KeyValue(node.opacityProperty(), 0, EASE)), - new KeyFrame(duration, new KeyValue(node.opacityProperty(), 1, EASE)) + new KeyFrame(Duration.millis(0), new KeyValue(node.opacityProperty(), 0, EASE)), + new KeyFrame(duration, new KeyValue(node.opacityProperty(), 1, EASE)) ); } public static Timeline fadeOut(Node node, Duration duration) { return new Timeline( - new KeyFrame(Duration.millis(0), new KeyValue(node.opacityProperty(), 1, EASE)), - new KeyFrame(duration, new KeyValue(node.opacityProperty(), 0, EASE)) + new KeyFrame(Duration.millis(0), new KeyValue(node.opacityProperty(), 1, EASE)), + new KeyFrame(duration, new KeyValue(node.opacityProperty(), 0, EASE)) ); } public static Timeline zoomIn(Node node, Duration duration) { return new Timeline( - new KeyFrame(Duration.millis(0), - new KeyValue(node.opacityProperty(), 0, EASE), - new KeyValue(node.scaleXProperty(), 0.3, EASE), - new KeyValue(node.scaleYProperty(), 0.3, EASE), - new KeyValue(node.scaleZProperty(), 0.3, EASE) - ), - new KeyFrame(duration, - new KeyValue(node.opacityProperty(), 1, EASE), - new KeyValue(node.scaleXProperty(), 1, EASE), - new KeyValue(node.scaleYProperty(), 1, EASE), - new KeyValue(node.scaleZProperty(), 1, EASE) - ) + new KeyFrame(Duration.millis(0), + new KeyValue(node.opacityProperty(), 0, EASE), + new KeyValue(node.scaleXProperty(), 0.3, EASE), + new KeyValue(node.scaleYProperty(), 0.3, EASE), + new KeyValue(node.scaleZProperty(), 0.3, EASE) + ), + new KeyFrame(duration, + new KeyValue(node.opacityProperty(), 1, EASE), + new KeyValue(node.scaleXProperty(), 1, EASE), + new KeyValue(node.scaleYProperty(), 1, EASE), + new KeyValue(node.scaleZProperty(), 1, EASE) + ) ); } public static Timeline zoomOut(Node node, Duration duration) { return new Timeline( - new KeyFrame(Duration.millis(0), - new KeyValue(node.opacityProperty(), 1, EASE), - new KeyValue(node.scaleXProperty(), 1, EASE), - new KeyValue(node.scaleYProperty(), 1, EASE), - new KeyValue(node.scaleZProperty(), 0.3, EASE) - ), - new KeyFrame(duration.divide(2), - new KeyValue(node.opacityProperty(), 0, EASE), - new KeyValue(node.scaleXProperty(), 0.3, EASE), - new KeyValue(node.scaleYProperty(), 0.3, EASE), - new KeyValue(node.scaleZProperty(), 0.3, EASE) - ), - new KeyFrame(duration, new KeyValue(node.opacityProperty(), 0, EASE)) + new KeyFrame(Duration.millis(0), + new KeyValue(node.opacityProperty(), 1, EASE), + new KeyValue(node.scaleXProperty(), 1, EASE), + new KeyValue(node.scaleYProperty(), 1, EASE), + new KeyValue(node.scaleZProperty(), 0.3, EASE) + ), + new KeyFrame(duration.divide(2), + new KeyValue(node.opacityProperty(), 0, EASE), + new KeyValue(node.scaleXProperty(), 0.3, EASE), + new KeyValue(node.scaleYProperty(), 0.3, EASE), + new KeyValue(node.scaleZProperty(), 0.3, EASE) + ), + new KeyFrame(duration, new KeyValue(node.opacityProperty(), 0, EASE)) ); } } diff --git a/sampler/src/main/java/atlantafx/sampler/util/Containers.java b/sampler/src/main/java/atlantafx/sampler/util/Containers.java index 4d98543..b21363f 100755 --- a/sampler/src/main/java/atlantafx/sampler/util/Containers.java +++ b/sampler/src/main/java/atlantafx/sampler/util/Containers.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.util; import static javafx.scene.layout.Region.USE_COMPUTED_SIZE; @@ -17,10 +18,18 @@ public final class Containers { public static final ColumnConstraints H_GROW_NEVER = columnConstraints(Priority.NEVER); public static void setAnchors(Node node, Insets insets) { - if (insets.getTop() >= 0) { AnchorPane.setTopAnchor(node, insets.getTop()); } - if (insets.getRight() >= 0) { AnchorPane.setRightAnchor(node, insets.getRight()); } - if (insets.getBottom() >= 0) { AnchorPane.setBottomAnchor(node, insets.getBottom()); } - if (insets.getLeft() >= 0) { AnchorPane.setLeftAnchor(node, insets.getLeft()); } + if (insets.getTop() >= 0) { + AnchorPane.setTopAnchor(node, insets.getTop()); + } + if (insets.getRight() >= 0) { + AnchorPane.setRightAnchor(node, insets.getRight()); + } + if (insets.getBottom() >= 0) { + AnchorPane.setBottomAnchor(node, insets.getBottom()); + } + if (insets.getLeft() >= 0) { + AnchorPane.setLeftAnchor(node, insets.getLeft()); + } } public static void setScrollConstraints(ScrollPane scrollPane, diff --git a/sampler/src/main/java/atlantafx/sampler/util/ContrastLevel.java b/sampler/src/main/java/atlantafx/sampler/util/ContrastLevel.java index cf14429..5e2dd27 100644 --- a/sampler/src/main/java/atlantafx/sampler/util/ContrastLevel.java +++ b/sampler/src/main/java/atlantafx/sampler/util/ContrastLevel.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.util; import static atlantafx.sampler.util.JColorUtils.flattenColor; @@ -48,8 +49,8 @@ public enum ContrastLevel { public static double getContrastRatio(double luminance1, double luminance2) { return 1 / (luminance1 > luminance2 ? - (luminance2 + 0.05) / (luminance1 + 0.05) : - (luminance1 + 0.05) / (luminance2 + 0.05) + (luminance2 + 0.05) / (luminance1 + 0.05) : + (luminance1 + 0.05) / (luminance2 + 0.05) ); } @@ -68,8 +69,8 @@ public enum ContrastLevel { */ public static double getColorLuminance(double[] rgb) { double[] tmp = Arrays.stream(rgb) - .map(v -> v <= 0.03928 ? (v / 12.92) : Math.pow((v + 0.055) / 1.055, 2.4)) - .toArray(); + .map(v -> v <= 0.03928 ? (v / 12.92) : Math.pow((v + 0.055) / 1.055, 2.4)) + .toArray(); return (tmp[0] * 0.2126) + (tmp[1] * 0.7152) + (tmp[2] * 0.0722); } @@ -77,6 +78,6 @@ public enum ContrastLevel { * See {@link ContrastLevel#getColorLuminance}. */ public static double getColorLuminance(Color color) { - return getColorLuminance(new double[]{color.getRed(), color.getGreen(), color.getBlue()}); + return getColorLuminance(new double[] {color.getRed(), color.getGreen(), color.getBlue()}); } } diff --git a/sampler/src/main/java/atlantafx/sampler/util/Controls.java b/sampler/src/main/java/atlantafx/sampler/util/Controls.java index 99779ae..f70c743 100644 --- a/sampler/src/main/java/atlantafx/sampler/util/Controls.java +++ b/sampler/src/main/java/atlantafx/sampler/util/Controls.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.util; import static atlantafx.base.theme.Styles.BUTTON_ICON; @@ -23,7 +24,9 @@ public final class Controls { public static Button button(String text, Ikon icon, boolean disable, String... styleClasses) { var button = new Button(text); - if (icon != null) { button.setGraphic(new FontIcon(icon)); } + if (icon != null) { + button.setGraphic(new FontIcon(icon)); + } button.setDisable(disable); button.getStyleClass().addAll(styleClasses); return button; @@ -36,8 +39,12 @@ public final class Controls { public static MenuItem menuItem(String text, Ikon graphic, KeyCombination accelerator, boolean disable) { var item = new MenuItem(text); - if (graphic != null) { item.setGraphic(new FontIcon(graphic)); } - if (accelerator != null) { item.setAccelerator(accelerator); } + if (graphic != null) { + item.setGraphic(new FontIcon(graphic)); + } + if (accelerator != null) { + item.setAccelerator(accelerator); + } item.setDisable(disable); return item; @@ -49,8 +56,12 @@ public final class Controls { boolean selected, String... styleClasses) { var toggleButton = new ToggleButton(text); - if (icon != null) { toggleButton.setGraphic(new FontIcon(icon)); } - if (group != null) { toggleButton.setToggleGroup(group); } + if (icon != null) { + toggleButton.setGraphic(new FontIcon(icon)); + } + if (group != null) { + toggleButton.setToggleGroup(group); + } toggleButton.setSelected(selected); toggleButton.getStyleClass().addAll(styleClasses); diff --git a/sampler/src/main/java/atlantafx/sampler/util/HumanReadableFormat.java b/sampler/src/main/java/atlantafx/sampler/util/HumanReadableFormat.java index dda6058..1ec7f60 100644 --- a/sampler/src/main/java/atlantafx/sampler/util/HumanReadableFormat.java +++ b/sampler/src/main/java/atlantafx/sampler/util/HumanReadableFormat.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.util; import java.text.CharacterIterator; @@ -18,7 +19,9 @@ public final class HumanReadableFormat { public static final DateTimeFormatter HOUR_MINUTE = DateTimeFormatter.ofPattern("HH:mm"); public static String byteCount(long bytes) { - if (-1000 < bytes && bytes < 1000) { return bytes + " B"; } + if (-1000 < bytes && bytes < 1000) { + return bytes + " B"; + } CharacterIterator ci = new StringCharacterIterator("kMGTPE"); while (bytes <= -999_950 || bytes >= 999_950) { bytes /= 1000; @@ -32,16 +35,24 @@ public final class HumanReadableFormat { var now = LocalDateTime.now(ZoneId.systemDefault()); // not this year - if (x.getYear() != now.getYear()) { return DAY_MONTH_YEAR.format(x); } + if (x.getYear() != now.getYear()) { + return DAY_MONTH_YEAR.format(x); + } // not this week - if (getWeekNumber(x) != getWeekNumber(now)) { return DAY_MONTH.format(x); } + if (getWeekNumber(x) != getWeekNumber(now)) { + return DAY_MONTH.format(x); + } // not today int xDay = x.getDayOfWeek().getValue(); int nowDay = now.getDayOfWeek().getValue(); - if (xDay == nowDay - 1) { return "Yesterday"; } - if (xDay != nowDay) { return DAY_OF_WEEK.format(x); } + if (xDay == nowDay - 1) { + return "Yesterday"; + } + if (xDay != nowDay) { + return DAY_OF_WEEK.format(x); + } return HOUR_MINUTE.format(x); } diff --git a/sampler/src/main/java/atlantafx/sampler/util/JColor.java b/sampler/src/main/java/atlantafx/sampler/util/JColor.java index 82f4f46..cd3e804 100644 --- a/sampler/src/main/java/atlantafx/sampler/util/JColor.java +++ b/sampler/src/main/java/atlantafx/sampler/util/JColor.java @@ -22,6 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ + package atlantafx.sampler.util; /** @@ -56,8 +57,7 @@ public class JColor { * Create the color in hex * * @param color hex color in format #RRGGBB, RRGGBB, #RGB, RGB, #AARRGGBB, - * AARRGGBB, #ARGB, or ARGB - * + * AARRGGBB, #ARGB, or ARGB * @return color */ public static JColor color(String color) { @@ -67,10 +67,9 @@ public class JColor { /** * Create the color in hex with an opacity * - * @param color hex color in format #RRGGBB, RRGGBB, #RGB, RGB, #AARRGGBB, - * AARRGGBB, #ARGB, or ARGB + * @param color hex color in format #RRGGBB, RRGGBB, #RGB, RGB, #AARRGGBB, + * AARRGGBB, #ARGB, or ARGB * @param opacity opacity float inclusively between 0.0 and 1.0 - * * @return color */ public static JColor color(String color, float opacity) { @@ -81,9 +80,8 @@ public class JColor { * Create the color in hex with an alpha * * @param color hex color in format #RRGGBB, RRGGBB, #RGB, RGB, #AARRGGBB, - * AARRGGBB, #ARGB, or ARGB + * AARRGGBB, #ARGB, or ARGB * @param alpha alpha integer color inclusively between 0 and 255 - * * @return color */ public static JColor color(String color, int alpha) { @@ -93,10 +91,9 @@ public class JColor { /** * Create the color with individual hex colors * - * @param red red hex color in format RR + * @param red red hex color in format RR * @param green green hex color in format GG - * @param blue blue hex color in format BB - * + * @param blue blue hex color in format BB * @return color */ public static JColor color(String red, String green, String blue) { @@ -106,11 +103,10 @@ public class JColor { /** * Create the color with individual hex colors and alpha * - * @param red red hex color in format RR + * @param red red hex color in format RR * @param green green hex color in format GG - * @param blue blue hex color in format BB + * @param blue blue hex color in format BB * @param alpha alpha hex color in format AA - * * @return color */ public static JColor color(String red, String green, String blue, @@ -121,11 +117,10 @@ public class JColor { /** * Create the color with individual hex colors and opacity * - * @param red red hex color in format RR - * @param green green hex color in format GG - * @param blue blue hex color in format BB + * @param red red hex color in format RR + * @param green green hex color in format GG + * @param blue blue hex color in format BB * @param opacity opacity float inclusively between 0.0 and 1.0 - * * @return color */ public static JColor color(String red, String green, String blue, @@ -136,10 +131,9 @@ public class JColor { /** * Create the color with RGB values * - * @param red red integer color inclusively between 0 and 255 + * @param red red integer color inclusively between 0 and 255 * @param green green integer color inclusively between 0 and 255 - * @param blue blue integer color inclusively between 0 and 255 - * + * @param blue blue integer color inclusively between 0 and 255 * @return color */ public static JColor color(int red, int green, int blue) { @@ -149,11 +143,10 @@ public class JColor { /** * Create the color with RGBA values * - * @param red red integer color inclusively between 0 and 255 + * @param red red integer color inclusively between 0 and 255 * @param green green integer color inclusively between 0 and 255 - * @param blue blue integer color inclusively between 0 and 255 + * @param blue blue integer color inclusively between 0 and 255 * @param alpha alpha integer color inclusively between 0 and 255 - * * @return color */ public static JColor color(int red, int green, int blue, int alpha) { @@ -163,11 +156,10 @@ public class JColor { /** * Create the color with RGBA values * - * @param red red integer color inclusively between 0 and 255 - * @param green green integer color inclusively between 0 and 255 - * @param blue blue integer color inclusively between 0 and 255 + * @param red red integer color inclusively between 0 and 255 + * @param green green integer color inclusively between 0 and 255 + * @param blue blue integer color inclusively between 0 and 255 * @param opacity opacity float inclusively between 0.0 and 1.0 - * * @return color */ public static JColor color(int red, int green, int blue, float opacity) { @@ -177,10 +169,9 @@ public class JColor { /** * Create the color with arithmetic RGB values * - * @param red red float color inclusively between 0.0 and 1.0 + * @param red red float color inclusively between 0.0 and 1.0 * @param green green float color inclusively between 0.0 and 1.0 - * @param blue blue float color inclusively between 0.0 and 1.0 - * + * @param blue blue float color inclusively between 0.0 and 1.0 * @return color */ public static JColor color(float red, float green, float blue) { @@ -190,11 +181,10 @@ public class JColor { /** * Create the color with arithmetic RGB values * - * @param red red float color inclusively between 0.0 and 1.0 - * @param green green float color inclusively between 0.0 and 1.0 - * @param blue blue float color inclusively between 0.0 and 1.0 + * @param red red float color inclusively between 0.0 and 1.0 + * @param green green float color inclusively between 0.0 and 1.0 + * @param blue blue float color inclusively between 0.0 and 1.0 * @param opacity opacity float inclusively between 0.0 and 1.0 - * * @return color */ public static JColor color(float red, float green, float blue, @@ -207,8 +197,7 @@ public class JColor { * values * * @param hsl HSL array where: 0 = hue, 1 = saturation, 2 = lightness, - * optional 3 = alpha - * + * optional 3 = alpha * @return color */ public static JColor color(float[] hsl) { @@ -218,9 +207,8 @@ public class JColor { /** * Create the color with HSLA (hue, saturation, lightness, alpha) values * - * @param hsl HSL array where: 0 = hue, 1 = saturation, 2 = lightness + * @param hsl HSL array where: 0 = hue, 1 = saturation, 2 = lightness * @param alpha alpha inclusively between 0.0 and 1.0 - * * @return color */ public static JColor color(float[] hsl, float alpha) { @@ -231,7 +219,6 @@ public class JColor { * Create the color as a single integer * * @param color color integer - * * @return color */ public static JColor color(int color) { @@ -249,7 +236,7 @@ public class JColor { * Create the color in hex * * @param color hex color in format #RRGGBB, RRGGBB, #RGB, RGB, #AARRGGBB, - * AARRGGBB, #ARGB, or ARGB + * AARRGGBB, #ARGB, or ARGB */ public JColor(String color) { setColor(color); @@ -258,8 +245,8 @@ public class JColor { /** * Create the color in hex with an opacity * - * @param color hex color in format #RRGGBB, RRGGBB, #RGB, RGB, #AARRGGBB, - * AARRGGBB, #ARGB, or ARGB + * @param color hex color in format #RRGGBB, RRGGBB, #RGB, RGB, #AARRGGBB, + * AARRGGBB, #ARGB, or ARGB * @param opacity opacity float inclusively between 0.0 and 1.0 */ public JColor(String color, float opacity) { @@ -270,7 +257,7 @@ public class JColor { * Create the color in hex with an alpha * * @param color hex color in format #RRGGBB, RRGGBB, #RGB, RGB, #AARRGGBB, - * AARRGGBB, #ARGB, or ARGB + * AARRGGBB, #ARGB, or ARGB * @param alpha alpha integer color inclusively between 0 and 255 */ public JColor(String color, int alpha) { @@ -280,9 +267,9 @@ public class JColor { /** * Create the color with individual hex colors * - * @param red red hex color in format RR + * @param red red hex color in format RR * @param green green hex color in format GG - * @param blue blue hex color in format BB + * @param blue blue hex color in format BB */ public JColor(String red, String green, String blue) { setColor(red, green, blue); @@ -291,9 +278,9 @@ public class JColor { /** * Create the color with individual hex colors and alpha * - * @param red red hex color in format RR + * @param red red hex color in format RR * @param green green hex color in format GG - * @param blue blue hex color in format BB + * @param blue blue hex color in format BB * @param alpha alpha hex color in format AA */ public JColor(String red, String green, String blue, String alpha) { @@ -303,9 +290,9 @@ public class JColor { /** * Create the color with individual hex colors and opacity * - * @param red red hex color in format RR - * @param green green hex color in format GG - * @param blue blue hex color in format BB + * @param red red hex color in format RR + * @param green green hex color in format GG + * @param blue blue hex color in format BB * @param opacity opacity float inclusively between 0.0 and 1.0 */ public JColor(String red, String green, String blue, float opacity) { @@ -315,9 +302,9 @@ public class JColor { /** * Create the color with RGB values * - * @param red red integer color inclusively between 0 and 255 + * @param red red integer color inclusively between 0 and 255 * @param green green integer color inclusively between 0 and 255 - * @param blue blue integer color inclusively between 0 and 255 + * @param blue blue integer color inclusively between 0 and 255 */ public JColor(int red, int green, int blue) { setColor(red, green, blue); @@ -326,9 +313,9 @@ public class JColor { /** * Create the color with RGBA values * - * @param red red integer color inclusively between 0 and 255 + * @param red red integer color inclusively between 0 and 255 * @param green green integer color inclusively between 0 and 255 - * @param blue blue integer color inclusively between 0 and 255 + * @param blue blue integer color inclusively between 0 and 255 * @param alpha alpha integer color inclusively between 0 and 255 */ public JColor(int red, int green, int blue, int alpha) { @@ -338,9 +325,9 @@ public class JColor { /** * Create the color with RGBA values * - * @param red red integer color inclusively between 0 and 255 - * @param green green integer color inclusively between 0 and 255 - * @param blue blue integer color inclusively between 0 and 255 + * @param red red integer color inclusively between 0 and 255 + * @param green green integer color inclusively between 0 and 255 + * @param blue blue integer color inclusively between 0 and 255 * @param opacity opacity float inclusively between 0.0 and 1.0 */ public JColor(int red, int green, int blue, float opacity) { @@ -350,9 +337,9 @@ public class JColor { /** * Create the color with arithmetic RGB values * - * @param red red float color inclusively between 0.0 and 1.0 + * @param red red float color inclusively between 0.0 and 1.0 * @param green green float color inclusively between 0.0 and 1.0 - * @param blue blue float color inclusively between 0.0 and 1.0 + * @param blue blue float color inclusively between 0.0 and 1.0 */ public JColor(float red, float green, float blue) { setColor(red, green, blue); @@ -361,9 +348,9 @@ public class JColor { /** * Create the color with arithmetic RGB values * - * @param red red float color inclusively between 0.0 and 1.0 - * @param green green float color inclusively between 0.0 and 1.0 - * @param blue blue float color inclusively between 0.0 and 1.0 + * @param red red float color inclusively between 0.0 and 1.0 + * @param green green float color inclusively between 0.0 and 1.0 + * @param blue blue float color inclusively between 0.0 and 1.0 * @param opacity opacity float inclusively between 0.0 and 1.0 */ public JColor(float red, float green, float blue, float opacity) { @@ -375,7 +362,7 @@ public class JColor { * values * * @param hsl HSL array where: 0 = hue, 1 = saturation, 2 = lightness, - * optional 3 = alpha + * optional 3 = alpha */ public JColor(float[] hsl) { if (hsl.length > 3) { @@ -388,7 +375,7 @@ public class JColor { /** * Create the color with HSLA (hue, saturation, lightness, alpha) values * - * @param hsl HSL array where: 0 = hue, 1 = saturation, 2 = lightness + * @param hsl HSL array where: 0 = hue, 1 = saturation, 2 = lightness * @param alpha alpha inclusively between 0.0 and 1.0 */ public JColor(float[] hsl, float alpha) { @@ -420,7 +407,7 @@ public class JColor { * Set the color in hex * * @param color hex color in format #RRGGBB, RRGGBB, #RGB, RGB, #AARRGGBB, - * AARRGGBB, #ARGB, or ARGB + * AARRGGBB, #ARGB, or ARGB */ public void setColor(String color) { setRed(JColorUtils.getRed(color)); @@ -435,8 +422,8 @@ public class JColor { /** * Set the color in hex with an opacity * - * @param color hex color in format #RRGGBB, RRGGBB, #RGB, RGB, #AARRGGBB, - * AARRGGBB, #ARGB, or ARGB + * @param color hex color in format #RRGGBB, RRGGBB, #RGB, RGB, #AARRGGBB, + * AARRGGBB, #ARGB, or ARGB * @param opacity opacity float inclusively between 0.0 and 1.0 */ public void setColor(String color, float opacity) { @@ -448,7 +435,7 @@ public class JColor { * Set the color in hex with an alpha * * @param color hex color in format #RRGGBB, RRGGBB, #RGB, RGB, #AARRGGBB, - * AARRGGBB, #ARGB, or ARGB + * AARRGGBB, #ARGB, or ARGB * @param alpha alpha integer color inclusively between 0 and 255 */ public void setColor(String color, int alpha) { @@ -459,9 +446,9 @@ public class JColor { /** * Set the color with individual hex colors * - * @param red red hex color in format RR + * @param red red hex color in format RR * @param green green hex color in format GG - * @param blue blue hex color in format BB + * @param blue blue hex color in format BB */ public void setColor(String red, String green, String blue) { setRed(red); @@ -472,9 +459,9 @@ public class JColor { /** * Set the color with individual hex colors and alpha * - * @param red red hex color in format RR + * @param red red hex color in format RR * @param green green hex color in format GG - * @param blue blue hex color in format BB + * @param blue blue hex color in format BB * @param alpha alpha hex color in format AA */ public void setColor(String red, String green, String blue, String alpha) { @@ -485,9 +472,9 @@ public class JColor { /** * Set the color with individual hex colors and opacity * - * @param red red hex color in format RR - * @param green green hex color in format GG - * @param blue blue hex color in format BB + * @param red red hex color in format RR + * @param green green hex color in format GG + * @param blue blue hex color in format BB * @param opacity opacity float inclusively between 0.0 and 1.0 */ public void setColor(String red, String green, String blue, float opacity) { @@ -498,9 +485,9 @@ public class JColor { /** * Set the color with RGB values * - * @param red red integer color inclusively between 0 and 255 + * @param red red integer color inclusively between 0 and 255 * @param green green integer color inclusively between 0 and 255 - * @param blue blue integer color inclusively between 0 and 255 + * @param blue blue integer color inclusively between 0 and 255 */ public void setColor(int red, int green, int blue) { setRed(red); @@ -511,9 +498,9 @@ public class JColor { /** * Set the color with RGBA values * - * @param red red integer color inclusively between 0 and 255 + * @param red red integer color inclusively between 0 and 255 * @param green green integer color inclusively between 0 and 255 - * @param blue blue integer color inclusively between 0 and 255 + * @param blue blue integer color inclusively between 0 and 255 * @param alpha alpha integer color inclusively between 0 and 255 */ public void setColor(int red, int green, int blue, int alpha) { @@ -524,9 +511,9 @@ public class JColor { /** * Set the color with RGBA values * - * @param red red integer color inclusively between 0 and 255 - * @param green green integer color inclusively between 0 and 255 - * @param blue blue integer color inclusively between 0 and 255 + * @param red red integer color inclusively between 0 and 255 + * @param green green integer color inclusively between 0 and 255 + * @param blue blue integer color inclusively between 0 and 255 * @param opacity opacity float inclusively between 0.0 and 1.0 */ public void setColor(int red, int green, int blue, float opacity) { @@ -537,9 +524,9 @@ public class JColor { /** * Set the color with arithmetic RGB values * - * @param red red float color inclusively between 0.0 and 1.0 + * @param red red float color inclusively between 0.0 and 1.0 * @param green green float color inclusively between 0.0 and 1.0 - * @param blue blue float color inclusively between 0.0 and 1.0 + * @param blue blue float color inclusively between 0.0 and 1.0 */ public void setColor(float red, float green, float blue) { setRed(red); @@ -550,9 +537,9 @@ public class JColor { /** * Set the color with arithmetic RGB values * - * @param red red float color inclusively between 0.0 and 1.0 - * @param green green float color inclusively between 0.0 and 1.0 - * @param blue blue float color inclusively between 0.0 and 1.0 + * @param red red float color inclusively between 0.0 and 1.0 + * @param green green float color inclusively between 0.0 and 1.0 + * @param blue blue float color inclusively between 0.0 and 1.0 * @param opacity opacity float inclusively between 0.0 and 1.0 */ public void setColor(float red, float green, float blue, float opacity) { @@ -563,13 +550,13 @@ public class JColor { /** * Set the color with HSL (hue, saturation, lightness) values * - * @param hue hue value inclusively between 0.0 and 360.0 + * @param hue hue value inclusively between 0.0 and 360.0 * @param saturation saturation inclusively between 0.0 and 1.0 - * @param lightness lightness inclusively between 0.0 and 1.0 + * @param lightness lightness inclusively between 0.0 and 1.0 */ public void setColorByHSL(float hue, float saturation, float lightness) { float[] arithmeticRGB = JColorUtils.toArithmeticRGB(hue, saturation, - lightness); + lightness); setRed(arithmeticRGB[0]); setGreen(arithmeticRGB[1]); setBlue(arithmeticRGB[2]); @@ -578,10 +565,10 @@ public class JColor { /** * Set the color with HSLA (hue, saturation, lightness, alpha) values * - * @param hue hue value inclusively between 0.0 and 360.0 + * @param hue hue value inclusively between 0.0 and 360.0 * @param saturation saturation inclusively between 0.0 and 1.0 - * @param lightness lightness inclusively between 0.0 and 1.0 - * @param alpha alpha inclusively between 0.0 and 1.0 + * @param lightness lightness inclusively between 0.0 and 1.0 + * @param alpha alpha inclusively between 0.0 and 1.0 */ public void setColorByHSL(float hue, float saturation, float lightness, float alpha) { @@ -749,7 +736,7 @@ public class JColor { */ public String getColorHexWithAlpha() { return JColorUtils.toColorWithAlpha(getRedHex(), getGreenHex(), - getBlueHex(), getAlphaHex()); + getBlueHex(), getAlphaHex()); } /** @@ -759,7 +746,7 @@ public class JColor { */ public String getColorHexShorthand() { return JColorUtils.toColorShorthand(getRedHex(), getGreenHex(), - getBlueHex()); + getBlueHex()); } /** @@ -769,7 +756,7 @@ public class JColor { */ public String getColorHexShorthandWithAlpha() { return JColorUtils.toColorShorthandWithAlpha(getRedHex(), getGreenHex(), - getBlueHex(), getAlphaHex()); + getBlueHex(), getAlphaHex()); } /** @@ -788,7 +775,7 @@ public class JColor { */ public int getColorWithAlpha() { return JColorUtils.toColorWithAlpha(getRed(), getGreen(), getBlue(), - getAlpha()); + getAlpha()); } /** diff --git a/sampler/src/main/java/atlantafx/sampler/util/JColorUtils.java b/sampler/src/main/java/atlantafx/sampler/util/JColorUtils.java index b67ef23..3af64f8 100644 --- a/sampler/src/main/java/atlantafx/sampler/util/JColorUtils.java +++ b/sampler/src/main/java/atlantafx/sampler/util/JColorUtils.java @@ -22,6 +22,7 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. */ + package atlantafx.sampler.util; import java.util.regex.Pattern; @@ -38,13 +39,13 @@ public class JColorUtils { * Hex color pattern */ private static final Pattern hexColorPattern = Pattern - .compile("^#?((\\p{XDigit}{3}){1,2}|(\\p{XDigit}{4}){1,2})$"); + .compile("^#?((\\p{XDigit}{3}){1,2}|(\\p{XDigit}{4}){1,2})$"); /** * Hex single color pattern */ private static final Pattern hexSingleColorPattern = Pattern - .compile("^\\p{XDigit}{1,2}$"); + .compile("^\\p{XDigit}{1,2}$"); /** * Convert the hex color values to a hex color @@ -84,7 +85,7 @@ public class JColorUtils { String blue) { String defaultAlpha = "FF"; if (red != null && !red.isEmpty() - && Character.isLowerCase(red.charAt(0))) { + && Character.isLowerCase(red.charAt(0))) { defaultAlpha = defaultAlpha.toLowerCase(); } return toColorWithAlpha(red, green, blue, defaultAlpha); @@ -314,7 +315,7 @@ public class JColorUtils { } } - return new float[] { hue, saturation, lightness }; + return new float[] {hue, saturation, lightness}; } /** @@ -328,7 +329,7 @@ public class JColorUtils { */ public static float[] toHSL(int red, int green, int blue) { return toHSL(toArithmeticRGB(red), toArithmeticRGB(green), - toArithmeticRGB(blue)); + toArithmeticRGB(blue)); } /** @@ -360,7 +361,7 @@ public class JColorUtils { float green = hslConvert(t1, t2, hue); float blue = hslConvert(t1, t2, hue - 2); - return new float[] { red, green, blue }; + return new float[] {red, green, blue}; } /** @@ -373,7 +374,7 @@ public class JColorUtils { */ public static int[] toRGB(float hue, float saturation, float lightness) { float[] arithmeticRGB = toArithmeticRGB(hue, saturation, lightness); - return new int[] { toRGB(arithmeticRGB[0]), toRGB(arithmeticRGB[1]), toRGB(arithmeticRGB[2]) }; + return new int[] {toRGB(arithmeticRGB[0]), toRGB(arithmeticRGB[1]), toRGB(arithmeticRGB[2])}; } /** @@ -538,7 +539,7 @@ public class JColorUtils { } for (; startIndex < color.length(); startIndex += 2) { String shorthand = shorthandHexSingle( - color.substring(startIndex, startIndex + 2)); + color.substring(startIndex, startIndex + 2)); if (shorthand.length() > 1) { shorthandColor = null; break; @@ -570,7 +571,7 @@ public class JColorUtils { } for (; startIndex < color.length(); startIndex++) { String expand = expandShorthandHexSingle( - color.substring(startIndex, startIndex + 1)); + color.substring(startIndex, startIndex + 1)); expandColor.append(expand); } color = expandColor.toString(); @@ -587,8 +588,8 @@ public class JColorUtils { public static String shorthandHexSingle(String color) { validateHexSingle(color); if (color.length() > 1 - && Character.toUpperCase(color.charAt(0)) == Character - .toUpperCase(color.charAt(1))) { + && Character.toUpperCase(color.charAt(0)) == Character + .toUpperCase(color.charAt(1))) { color = color.substring(0, 1); } return color; @@ -626,8 +627,8 @@ public class JColorUtils { public static void validateHex(String color) { if (!isValidHex(color)) { throw new IllegalArgumentException( - "Hex color must be in format #RRGGBB, #RGB, #AARRGGBB, #ARGB, RRGGBB, RGB, AARRGGBB, or ARGB, invalid value: " - + color); + "Hex color must be in format #RRGGBB, #RGB, #AARRGGBB, #ARGB, RRGGBB, RGB, AARRGGBB, or ARGB, invalid value: " + + color); } } @@ -649,7 +650,7 @@ public class JColorUtils { public static void validateHexSingle(String color) { if (!isValidHexSingle(color)) { throw new IllegalArgumentException( - "Must be in format FF or F, invalid value: " + color); + "Must be in format FF or F, invalid value: " + color); } } @@ -671,8 +672,8 @@ public class JColorUtils { public static void validateRGB(int color) { if (!isValidRGB(color)) { throw new IllegalArgumentException( - "Must be inclusively between 0 and 255, invalid value: " - + color); + "Must be inclusively between 0 and 255, invalid value: " + + color); } } @@ -696,8 +697,8 @@ public class JColorUtils { public static void validateArithmeticRGB(float color) { if (!isValidArithmeticRGB(color)) { throw new IllegalArgumentException( - "Must be inclusively between 0.0 and 1.0, invalid value: " - + color); + "Must be inclusively between 0.0 and 1.0, invalid value: " + + color); } } @@ -720,8 +721,8 @@ public class JColorUtils { public static void validateHue(float hue) { if (!isValidHue(hue)) { throw new IllegalArgumentException( - "Must be inclusively between 0.0 and 360.0, invalid value: " - + hue); + "Must be inclusively between 0.0 and 360.0, invalid value: " + + hue); } } @@ -745,8 +746,8 @@ public class JColorUtils { public static void validateSaturation(float saturation) { if (!isValidSaturation(saturation)) { throw new IllegalArgumentException( - "Must be inclusively between 0.0 and 1.0, invalid value: " - + saturation); + "Must be inclusively between 0.0 and 1.0, invalid value: " + + saturation); } } @@ -769,8 +770,8 @@ public class JColorUtils { public static void validateLightness(float lightness) { if (!isValidLightness(lightness)) { throw new IllegalArgumentException( - "Must be inclusively between 0.0 and 1.0, invalid value: " - + lightness); + "Must be inclusively between 0.0 and 1.0, invalid value: " + + lightness); } } @@ -804,16 +805,16 @@ public class JColorUtils { public static double[] flattenColor(Color bg, Color fgColor) { var opacity = fgColor.getOpacity(); return opacity < 1 ? - new double[] { - opacity * fgColor.getRed() + (1 - opacity) * bg.getRed(), - opacity * fgColor.getGreen() + (1 - opacity) * bg.getGreen(), - opacity * fgColor.getBlue() + (1 - opacity) * bg.getBlue(), - } : - new double[] { - fgColor.getRed(), - fgColor.getGreen(), - fgColor.getBlue(), - }; + new double[] { + opacity * fgColor.getRed() + (1 - opacity) * bg.getRed(), + opacity * fgColor.getGreen() + (1 - opacity) * bg.getGreen(), + opacity * fgColor.getBlue() + (1 - opacity) * bg.getBlue(), + } : + new double[] { + fgColor.getRed(), + fgColor.getGreen(), + fgColor.getBlue(), + }; } /** @@ -822,35 +823,35 @@ public class JColorUtils { */ public static Color opaqueColor(Color bgColor, Color targetColor, double targetOpacity) { return Color.color( - bgColor.getRed() + (targetColor.getRed() - bgColor.getRed()) * targetOpacity, - bgColor.getGreen() + (targetColor.getGreen() - bgColor.getGreen()) * targetOpacity, - bgColor.getBlue() + (targetColor.getBlue() - bgColor.getBlue()) * targetOpacity, - targetOpacity + bgColor.getRed() + (targetColor.getRed() - bgColor.getRed()) * targetOpacity, + bgColor.getGreen() + (targetColor.getGreen() - bgColor.getGreen()) * targetOpacity, + bgColor.getBlue() + (targetColor.getBlue() - bgColor.getBlue()) * targetOpacity, + targetOpacity ); } public static float[] toHSL(Color color) { return JColorUtils.toHSL( - (float) color.getRed(), - (float) color.getGreen(), - (float) color.getBlue() + (float) color.getRed(), + (float) color.getGreen(), + (float) color.getBlue() ); } public static String toHexWithAlpha(Color color) { return JColor.color( - (float) color.getRed(), - (float) color.getGreen(), - (float) color.getBlue(), - (float) color.getOpacity() + (float) color.getRed(), + (float) color.getGreen(), + (float) color.getBlue(), + (float) color.getOpacity() ).getColorHexShorthandWithAlpha(); } public static String toHexOpaque(Color color) { return JColor.color( - (float) color.getRed(), - (float) color.getGreen(), - (float) color.getBlue() + (float) color.getRed(), + (float) color.getGreen(), + (float) color.getBlue() ).getColorHexShorthandWithAlpha(); } } diff --git a/sampler/src/main/java/atlantafx/sampler/util/NodeUtils.java b/sampler/src/main/java/atlantafx/sampler/util/NodeUtils.java index 4c6bd83..dadb0d4 100644 --- a/sampler/src/main/java/atlantafx/sampler/util/NodeUtils.java +++ b/sampler/src/main/java/atlantafx/sampler/util/NodeUtils.java @@ -1,4 +1,5 @@ /* SPDX-License-Identifier: MIT */ + package atlantafx.sampler.util; import java.util.List; @@ -20,16 +21,22 @@ public final class NodeUtils { public static T getChildByIndex(Parent parent, int index, Class contentType) { List children = parent.getChildrenUnmodifiable(); - if (index < 0 || index >= children.size()) { return null; } + if (index < 0 || index >= children.size()) { + return null; + } Node node = children.get(index); return contentType.isInstance(node) ? contentType.cast(node) : null; } public static boolean isDescendant(Node ancestor, Node descendant) { - if (ancestor == null) { return true; } + if (ancestor == null) { + return true; + } while (descendant != null) { - if (descendant == ancestor) { return true; } + if (descendant == ancestor) { + return true; + } descendant = descendant.getParent(); } return false;