java.lang.Object
com.dua3.utility.fx.FxUtil
JavaFX utility class.
-
Feldübersicht
FelderModifizierer und TypFeldBeschreibungstatic final ObservableBooleanValueA static constant representing a boolean property with a fixed value offalse.static final ObservableBooleanValueA constant ObservableBooleanValue that always holds the valuetrue. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungstatic voidaddMouseEventHandler(Node node, EventType<MouseEvent> eventType, EventHandler<? super MouseEvent> handler) Attaches a mouse event handler to a given node for a specific event type.static com.dua3.utility.data.Converter<com.dua3.utility.data.Color, Color> Creates and returns a converter between com.dua3.utility.data.Color and javafx.scene.paint.Color.static ObservableBooleanValueconstant(boolean b) Returns an ObservableBooleanValue that represents the specified boolean constant.static Colorconvert(com.dua3.utility.data.Color color) ConvertColortoColor.static Affineconvert(com.dua3.utility.math.geometry.AffineTransformation2f at) ConvertAffineTransformation2fto JavaFXAffine.static FillRuleconvert(com.dua3.utility.math.geometry.FillRule rule) ConvertFillRuleto JavaFXFillRule.static Pathconvert(com.dua3.utility.math.geometry.Path2f path) Converts aPath2fobject to aPathobject.static Rectangleconvert(com.dua3.utility.math.geometry.Rectangle2f r) Convert aRectangle2fobject to a JavaFXRectangleobject.static Fontconvert(com.dua3.utility.text.Font font) ConvertFontto JavaFXFont.static com.dua3.utility.math.geometry.Rectangle2fConvert a JavaFXBoundsobject to aRectangle2fobject.static com.dua3.utility.math.geometry.Rectangle2fConvert a JavaFXRectangleobject to aRectangle2fobject.static com.dua3.utility.data.ColorConverttoColor.static com.dua3.utility.math.geometry.FillRuleConvertFillRuleto JavaFXFillRule.static com.dua3.utility.text.FontConvert JavaFXFonttoFont.static com.dua3.utility.math.geometry.AffineTransformation2fConvert JavaFXAffinetoAffineTransformation2f.static PathconvertToJavaFxPath(com.dua3.utility.math.geometry.Path2f path) Converts a Path2f object to a JavaFX Path.static voidcopyToClipboard(com.dua3.utility.data.Image img) Copy image to clipboard.static voidcopyToClipboard(com.dua3.utility.text.RichText text) Copy text to clipboard.static voidCopy text to clipboard.static voidcopyToClipboard(Path path) Copy file/folder to clipboard.static voidcopyToClipboard(Collection<? extends Path> paths) Copy files/folders to clipboard.static voidcopyToClipboard(Image img) Copy image to clipboard.static EventHandler<DragEvent> dragEventHandler(Function<? super List<Path>, ? extends Collection<TransferMode>> modeGetter) Create anEventHandler<DragEvent>that accepts dragging files.static EventHandler<DragEvent> dropEventHandler(Consumer<? super List<Path>> processor) Create anEventHandler<DragEvent>that accepts paths.static com.dua3.utility.data.Converter<com.dua3.utility.text.Font, Font> Provides a converter between com.dua3.utility.text.Font and javafx.scene.text.Font.static com.dua3.utility.math.geometry.Scale2fgetDisplayScale(Screen screen) Retrieves the display scale of a givenScreen.static com.dua3.utility.math.geometry.Scale2fgetDisplayScale(Window window) Returns the display scale of the given window.static Collection<Path> Retrieves a collection of file paths from the system clipboard.static Optional<com.dua3.utility.data.Image> Retrieves an image from the system clipboard if one is available.static ScreenReturns the Screen where the given Window is located.Retrieves a string from the system clipboard if available.static BoundsgetTextBounds(CharSequence s, com.dua3.utility.text.Font f) Returns the bounds of the given text string when rendered with the specified font.static BoundsgetTextBounds(CharSequence s, Font f) Returns the bounds of the given text string when rendered with the specified font.static doublegetTextHeight(CharSequence s, com.dua3.utility.text.Font f) Returns the height of the given text string when rendered with the specified font.static doublegetTextWidth(CharSequence s, com.dua3.utility.text.Font f) Returns the width of the given text string when rendered with the specified font.static Dimension2DgrowToFit(Dimension2D a, Bounds b) Calculates the dimensions required for a givenDimension2Dobject to fit within the specifiedBounds.static <A,B> ObservableList <B> map(ObservableList<A> list, Function<A, B> mapping) Maps each element of the given ObservableList using the provided mapping function.static booleanmatches(FileChooser.ExtensionFilter filter, File file) Test if filename matches filter.static booleanmatches(FileChooser.ExtensionFilter filter, String filename) Test if filename matches filter.static booleanmatches(FileChooser.ExtensionFilter filter, URI uri) Test if URI matches filter.static booleanmatches(FileChooser.ExtensionFilter filter, Path file) Test if file matches filter.static <T extends @Nullable Object>
ObservableValue<T> toObservableValue(com.dua3.utility.concurrent.Value<T> value) Converts aValueobject into anObservableValue.static Rectangle2Dunion(Rectangle2D r1, Rectangle2D r2) Create the union of two rectangles.
-
Felddetails
-
TRUE
A constant ObservableBooleanValue that always holds the valuetrue. This variable is immutable and can be reliably used wherever a constant boolean value oftrueis required in an observable context. -
FALSE
A static constant representing a boolean property with a fixed value offalse. This property is immutable and can be used wherever anObservableBooleanValuewith a value offalseis required.
-
-
Methodendetails
-
convert
ConvertColortoColor.- Parameter:
color- the color- Gibt zurück:
- the JavaFX color
-
convert
ConverttoColor.- Parameter:
color- the JavaFX color- Gibt zurück:
- the color
-
convert
ConvertFillRuleto JavaFXFillRule.- Parameter:
rule- the fill rule- Gibt zurück:
- the JavaFX fill rule
-
convert
ConvertFillRuleto JavaFXFillRule.- Parameter:
rule- JavaFX the fill rule- Gibt zurück:
- the fill rule
-
convert
ConvertAffineTransformation2fto JavaFXAffine.- Parameter:
at- the affine transformation- Gibt zurück:
- the JavaFX affine transformation
-
convert
Convert JavaFXAffinetoAffineTransformation2f.- Parameter:
a- the JavaFX affine transformation- Gibt zurück:
- the affine transformation
-
convert
Converts aPath2fobject to aPathobject.- Parameter:
path- thePath2fobject to convert- Gibt zurück:
- the converted javafx.scene.shape.Path object
- Löst aus:
IllegalArgumentException- if the path contains unsupported segment types
-
convert
Convert aRectangle2fobject to a JavaFXRectangleobject.- Parameter:
r- theRectangle2fobject to convert- Gibt zurück:
- the converted JavaFX Rectangle object
-
convert
Convert a JavaFXRectangleobject to aRectangle2fobject.- Parameter:
r- the Rectangle object to convert- Gibt zurück:
- the converted
Rectangle2fobject
-
convert
Convert a JavaFXBoundsobject to aRectangle2fobject.- Parameter:
b- theBoundsobject to convert- Gibt zurück:
- the converted
Rectangle2fobject
-
getTextBounds
Returns the bounds of the given text string when rendered with the specified font.- Parameter:
s- the text stringf- the font- Gibt zurück:
- the bounds of the text string
-
getTextBounds
Returns the bounds of the given text string when rendered with the specified font.- Parameter:
s- the text stringf- the font- Gibt zurück:
- the bounds of the text string
-
convert
ConvertFontto JavaFXFont.- Parameter:
font- the font- Gibt zurück:
- the JavaFX Font
-
convert
Convert JavaFXFonttoFont.- Parameter:
fxFont- the font- Gibt zurück:
- the JavaFX Font
-
getTextWidth
Returns the width of the given text string when rendered with the specified font.- Parameter:
s- the text stringf- the font- Gibt zurück:
- the width of the text string
-
getTextHeight
Returns the height of the given text string when rendered with the specified font.- Parameter:
s- the text stringf- the font- Gibt zurück:
- the height of the text string
-
growToFit
Calculates the dimensions required for a givenDimension2Dobject to fit within the specifiedBounds.- Parameter:
a- the original dimensionb- the bounds to fit into- Gibt zurück:
- a new Dimension2D object with the adjusted dimensions
-
matches
Test if file matches filter.- Parameter:
filter- the filterfile- the file- Gibt zurück:
- true if filename matches filter
-
matches
Test if filename matches filter.- Parameter:
filter- the filterfilename- the filename- Gibt zurück:
- true if filename matches filter
-
matches
Test if filename matches filter.- Parameter:
filter- the filterfile- the file- Gibt zurück:
- true if file matches filter
-
matches
Test if URI matches filter.- Parameter:
filter- the filteruri- the URI- Gibt zurück:
- true if file matches filter
-
copyToClipboard
Copy text to clipboard.- Parameter:
s- the text
-
copyToClipboard
public static void copyToClipboard(com.dua3.utility.text.RichText text) Copy text to clipboard.- Parameter:
text- the text
-
copyToClipboard
public static void copyToClipboard(com.dua3.utility.data.Image img) Copy image to clipboard.- Parameter:
img- the image
-
copyToClipboard
Copy image to clipboard.- Parameter:
img- the image
-
copyToClipboard
Copy file/folder to clipboard.- Parameter:
path- the path to the file/folder to copy to the clipboard
-
copyToClipboard
Copy files/folders to clipboard.- Parameter:
paths- the list of paths to copy to the clipboard
-
getStringFromClipboard
Retrieves a string from the system clipboard if available.- Gibt zurück:
- an
Optionalcontaining the string from the clipboard if present, or an emptyOptionalotherwise
-
getImageFromClipboard
Retrieves an image from the system clipboard if one is available.- Gibt zurück:
- an
Optionalcontaining the image if the clipboard contains an image, or an emptyOptionalif no image is present in the clipboard.
-
getFilesFromClipboard
Retrieves a collection of file paths from the system clipboard. If the clipboard contains files, their paths are returned as a collection. Otherwise, an empty collection is returned.- Gibt zurück:
- A collection of file paths retrieved from the clipboard or an empty collection if no files are present on the clipboard.
-
dragEventHandler
public static EventHandler<DragEvent> dragEventHandler(Function<? super List<Path>, ? extends Collection<TransferMode>> modeGetter) Create anEventHandler<DragEvent>that accepts dragging files.- Parameter:
modeGetter- Function that determines the supportedTransferModes. Should return an empty list if the drag is not accepted.- Gibt zurück:
- event handler
-
dropEventHandler
Create anEventHandler<DragEvent>that accepts paths.- Parameter:
processor- consumer that processes the drop event- Gibt zurück:
- event handler
-
union
Create the union of two rectangles. The union here is defined as the rectangle r of minimum size that contains both rectangles r1 and r2.- Parameter:
r1- first rectangler2- second rectangle- Gibt zurück:
- minimal rectangle containing both r1 and r2
-
toObservableValue
public static <T extends @Nullable Object> ObservableValue<T> toObservableValue(com.dua3.utility.concurrent.Value<T> value) Converts aValueobject into anObservableValue.- Typparameter:
T- the type of the value stored in the Value object- Parameter:
value- the Value object to be converted- Gibt zurück:
- an ObservableValue object that reflects changes in the Value object
-
addMouseEventHandler
public static void addMouseEventHandler(Node node, EventType<MouseEvent> eventType, EventHandler<? super MouseEvent> handler) Attaches a mouse event handler to a given node for a specific event type.If an event handler is already registered, the new handler is called first. If the event is not consumed by the# handler, the old handler is called too.
- Parameter:
node- The node to attach the mouse event handler to.eventType- The type of the mouse event to handle.handler- The event handler to be called when the specified mouse event occurs.
-
map
Maps each element of the given ObservableList using the provided mapping function.- Typparameter:
A- the type of elements in the original listB- the type of elements returned by the mapping function- Parameter:
list- the ObservableList to be mappedmapping- the mapping function to apply to each element of the list- Gibt zurück:
- a new ObservableList containing the mapped elements
-
getDisplayScale
Retrieves the display scale of a givenScreen.- Parameter:
screen- the screen for which to retrieve the display scale- Gibt zurück:
- the display scale of the screen, or the default scale if no
GraphicsConfigurationis set for the component
-
getDisplayScale
Returns the display scale of the given window. The display scale is a scaling factor that is applied to the window's content to adjust for high-resolution displays.- Parameter:
window- the window for which to retrieve the display scale- Gibt zurück:
- the scale factor applied to the window's content
-
convertToJavaFxPath
Converts a Path2f object to a JavaFX Path.- Parameter:
path- the Path2f object containing segments to be converted to a JavaFX Path- Gibt zurück:
- a JavaFX Path object representing the equivalent structure of the input Path2f
- Löst aus:
IllegalArgumentException- if an unsupported segment type or unsupported number of control points is encountered
-
getScreen
Returns the Screen where the given Window is located.- Parameter:
window- the Window to get the Screen for- Gibt zurück:
- the Screen where the window is located or the primary screen if the screen could not be determined
-
constant
Returns an ObservableBooleanValue that represents the specified boolean constant.- Parameter:
b- the boolean value to be wrapped as an ObservableBooleanValue- Gibt zurück:
- an ObservableBooleanValue representing the specified boolean
-
fontConverter
Provides a converter between com.dua3.utility.text.Font and javafx.scene.text.Font.- Gibt zurück:
- a Converter instance that can convert between com.dua3.utility.text.Font and javafx.scene.text.Font.
-
colorConverter
Creates and returns a converter between com.dua3.utility.data.Color and javafx.scene.paint.Color.- Gibt zurück:
- a bidirectional converter that facilitates conversion between com.dua3.utility.data.Color and javafx.scene.paint.Color.
-