Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
✨ Added fluent API builders for MaterialFX components and JavaFX pane…
…s, as requested by #78 Signed-off-by: palexdev <alessandro.parisi406@gmail.com>
- Loading branch information
Showing
52 changed files
with
5,220 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
85 changes: 85 additions & 0 deletions
85
...rialfx/src/main/java/io/github/palexdev/materialfx/builders/base/BaseListViewBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
/* | ||
* Copyright (C) 2022 Parisi Alessandro | ||
* This file is part of MaterialFX (https://github.com/palexdev/MaterialFX). | ||
* | ||
* MaterialFX is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* MaterialFX is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with MaterialFX. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.github.palexdev.materialfx.builders.base; | ||
|
||
import io.github.palexdev.materialfx.controls.base.AbstractMFXListView; | ||
import io.github.palexdev.materialfx.effects.DepthLevel; | ||
import io.github.palexdev.virtualizedfx.cell.Cell; | ||
import javafx.collections.ObservableList; | ||
import javafx.scene.paint.Paint; | ||
import javafx.util.Duration; | ||
import javafx.util.StringConverter; | ||
|
||
public class BaseListViewBuilder<T, C extends Cell<T>, L extends AbstractMFXListView<T, C>> extends ControlBuilder<L> { | ||
|
||
//================================================================================ | ||
// Constructors | ||
//================================================================================ | ||
public BaseListViewBuilder(L control) { | ||
super(control); | ||
} | ||
|
||
public static <T, C extends Cell<T>> BaseListViewBuilder<T, C, AbstractMFXListView<T, C>> baseList(AbstractMFXListView<T, C> list) { | ||
return new BaseListViewBuilder<>(list); | ||
} | ||
|
||
//================================================================================ | ||
// Delegate Methods | ||
//================================================================================ | ||
|
||
public BaseListViewBuilder<T, C, L> setTrackColor(Paint trackColor) { | ||
node.setTrackColor(trackColor); | ||
return this; | ||
} | ||
|
||
public BaseListViewBuilder<T, C, L> setThumbColor(Paint thumbColor) { | ||
node.setThumbColor(thumbColor); | ||
return this; | ||
} | ||
|
||
public BaseListViewBuilder<T, C, L> setThumbHoverColor(Paint thumbHoverColor) { | ||
node.setThumbHoverColor(thumbHoverColor); | ||
return this; | ||
} | ||
|
||
public BaseListViewBuilder<T, C, L> setHideAfter(Duration hideAfter) { | ||
node.setHideAfter(hideAfter); | ||
return this; | ||
} | ||
|
||
public BaseListViewBuilder<T, C, L> setItems(ObservableList<T> items) { | ||
node.setItems(items); | ||
return this; | ||
} | ||
|
||
public BaseListViewBuilder<T, C, L> setConverter(StringConverter<T> converter) { | ||
node.setConverter(converter); | ||
return this; | ||
} | ||
|
||
public BaseListViewBuilder<T, C, L> setHideScrollBars(boolean hideScrollBars) { | ||
node.setHideScrollBars(hideScrollBars); | ||
return this; | ||
} | ||
|
||
public BaseListViewBuilder<T, C, L> setDepthLevel(DepthLevel depthLevel) { | ||
node.setDepthLevel(depthLevel); | ||
return this; | ||
} | ||
} |
53 changes: 53 additions & 0 deletions
53
...rialfx/src/main/java/io/github/palexdev/materialfx/builders/base/BaseProgressBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
* Copyright (C) 2022 Parisi Alessandro | ||
* This file is part of MaterialFX (https://github.com/palexdev/MaterialFX). | ||
* | ||
* MaterialFX is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* MaterialFX is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with MaterialFX. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.github.palexdev.materialfx.builders.base; | ||
|
||
import javafx.scene.control.ProgressIndicator; | ||
|
||
public class BaseProgressBuilder<P extends ProgressIndicator> extends ControlBuilder<P> { | ||
|
||
//================================================================================ | ||
// Constructors | ||
//================================================================================ | ||
@SuppressWarnings("unchecked") | ||
public BaseProgressBuilder() { | ||
this((P) new ProgressIndicator()); | ||
} | ||
|
||
public BaseProgressBuilder(P progressIndicator) { | ||
super(progressIndicator); | ||
} | ||
|
||
public static BaseProgressBuilder<ProgressIndicator> progressIndicator() { | ||
return new BaseProgressBuilder<>(); | ||
} | ||
|
||
public static BaseProgressBuilder<ProgressIndicator> progressIndicator(ProgressIndicator progressIndicator) { | ||
return new BaseProgressBuilder<>(progressIndicator); | ||
} | ||
|
||
//================================================================================ | ||
// Delegate Methods | ||
//================================================================================ | ||
|
||
public BaseProgressBuilder<P> setProgress(double value) { | ||
node.setProgress(value); | ||
return this; | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
...alfx/src/main/java/io/github/palexdev/materialfx/builders/base/BaseToggleNodeBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright (C) 2022 Parisi Alessandro | ||
* This file is part of MaterialFX (https://github.com/palexdev/MaterialFX). | ||
* | ||
* MaterialFX is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* MaterialFX is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with MaterialFX. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.github.palexdev.materialfx.builders.base; | ||
|
||
import io.github.palexdev.materialfx.controls.base.AbstractMFXToggleNode; | ||
import javafx.scene.Node; | ||
import javafx.scene.control.ToggleGroup; | ||
|
||
public class BaseToggleNodeBuilder<T extends AbstractMFXToggleNode> extends ButtonBaseBuilder<T> { | ||
|
||
//================================================================================ | ||
// Constructors | ||
//================================================================================ | ||
public BaseToggleNodeBuilder(T toggleNode) { | ||
super(toggleNode); | ||
} | ||
|
||
public static BaseToggleNodeBuilder<AbstractMFXToggleNode> toggleNode(AbstractMFXToggleNode toggleNode) { | ||
return new BaseToggleNodeBuilder<>(toggleNode); | ||
} | ||
|
||
//================================================================================ | ||
// Delegate Methods | ||
//================================================================================ | ||
|
||
public BaseToggleNodeBuilder<T> setLabelLeadingIcon(Node labelLeadingIcon) { | ||
node.setLabelLeadingIcon(labelLeadingIcon); | ||
return this; | ||
} | ||
|
||
public BaseToggleNodeBuilder<T> setLabelTrailingIcon(Node labelTrailingIcon) { | ||
node.setLabelTrailingIcon(labelTrailingIcon); | ||
return this; | ||
} | ||
|
||
public BaseToggleNodeBuilder<T> setSelected(boolean value) { | ||
node.setSelected(value); | ||
return this; | ||
} | ||
|
||
public BaseToggleNodeBuilder<T> setToggleGroup(ToggleGroup value) { | ||
node.setToggleGroup(value); | ||
return this; | ||
} | ||
} |
61 changes: 61 additions & 0 deletions
61
materialfx/src/main/java/io/github/palexdev/materialfx/builders/base/ButtonBaseBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
/* | ||
* Copyright (C) 2022 Parisi Alessandro | ||
* This file is part of MaterialFX (https://github.com/palexdev/MaterialFX). | ||
* | ||
* MaterialFX is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* MaterialFX is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with MaterialFX. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.github.palexdev.materialfx.builders.base; | ||
|
||
import javafx.event.ActionEvent; | ||
import javafx.event.EventHandler; | ||
import javafx.scene.control.ButtonBase; | ||
|
||
public class ButtonBaseBuilder<B extends ButtonBase> extends LabeledBuilder<B> { | ||
|
||
//================================================================================ | ||
// Constructors | ||
//================================================================================ | ||
public ButtonBaseBuilder(B buttonBase) { | ||
super(buttonBase); | ||
} | ||
|
||
public static ButtonBaseBuilder<ButtonBase> control(ButtonBase buttonBase) { | ||
return new ButtonBaseBuilder<>(buttonBase); | ||
} | ||
|
||
//================================================================================ | ||
// Delegate Methods | ||
//================================================================================ | ||
|
||
public ButtonBaseBuilder<B> setOnAction(EventHandler<ActionEvent> handler) { | ||
node.setOnAction(handler); | ||
return this; | ||
} | ||
|
||
public ButtonBaseBuilder<B> arm() { | ||
node.arm(); | ||
return this; | ||
} | ||
|
||
public ButtonBaseBuilder<B> disarm() { | ||
node.disarm(); | ||
return this; | ||
} | ||
|
||
public ButtonBaseBuilder<B> fire() { | ||
node.fire(); | ||
return this; | ||
} | ||
} |
58 changes: 58 additions & 0 deletions
58
materialfx/src/main/java/io/github/palexdev/materialfx/builders/base/ControlBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
/* | ||
* Copyright (C) 2022 Parisi Alessandro | ||
* This file is part of MaterialFX (https://github.com/palexdev/MaterialFX). | ||
* | ||
* MaterialFX is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* MaterialFX is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with MaterialFX. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.github.palexdev.materialfx.builders.base; | ||
|
||
import io.github.palexdev.materialfx.builders.layout.RegionBuilder; | ||
import javafx.scene.control.ContextMenu; | ||
import javafx.scene.control.Control; | ||
import javafx.scene.control.Skin; | ||
import javafx.scene.control.Tooltip; | ||
|
||
public class ControlBuilder<C extends Control> extends RegionBuilder<C> { | ||
|
||
//================================================================================ | ||
// Constructors | ||
//================================================================================ | ||
public ControlBuilder(C control) { | ||
super(control); | ||
} | ||
|
||
public static ControlBuilder<Control> control(Control control) { | ||
return new ControlBuilder<>(control); | ||
} | ||
|
||
//================================================================================ | ||
// Delegate Methods | ||
//================================================================================ | ||
|
||
public ControlBuilder<C> setSkin(Skin<?> value) { | ||
node.setSkin(value); | ||
return this; | ||
} | ||
|
||
public ControlBuilder<C> setTooltip(Tooltip value) { | ||
node.setTooltip(value); | ||
return this; | ||
} | ||
|
||
public ControlBuilder<C> setContextMenu(ContextMenu value) { | ||
node.setContextMenu(value); | ||
return this; | ||
} | ||
} |
25 changes: 25 additions & 0 deletions
25
materialfx/src/main/java/io/github/palexdev/materialfx/builders/base/INodeBuilder.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
/* | ||
* Copyright (C) 2022 Parisi Alessandro | ||
* This file is part of MaterialFX (https://github.com/palexdev/MaterialFX). | ||
* | ||
* MaterialFX is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as published by | ||
* the Free Software Foundation, either version 3 of the License, or | ||
* (at your option) any later version. | ||
* | ||
* MaterialFX is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public License | ||
* along with MaterialFX. If not, see <http://www.gnu.org/licenses/>. | ||
*/ | ||
|
||
package io.github.palexdev.materialfx.builders.base; | ||
|
||
import javafx.scene.Node; | ||
|
||
public interface INodeBuilder<N extends Node> { | ||
N getNode(); | ||
} |
Oops, something went wrong.