I very much like the idea of a simpler way to create Borders and Backgrounds, 
but once you get beyond the original proposal of Border.stroke(Paint stroke), 
it  seems like a case where a fluent interface would be useful. The 
alternatives of multiple argument constructors just start getting back into 
more complexity and debates about who needs what combination of options 
supported.
 

So if one wanted a simple border:

    Border.stroke(Color.RED)

but if you want to set width and styles you could do something like:

   Border.stroke(Color.RED).width(3).dotted();

—Bruce

> On Jun 9, 2021, at 7:59 AM, John Hendrikx <hj...@xs4all.nl> wrote:
> 
> I'm not entirely convinced taking width is all that useful. The (final) pxiel 
> width of a border is normally a calculated value based on the chosen unit and 
> scaling needs of the platform.
> 
> A lot of methods in JavaFX work with pixel values only, while for proper 
> scaling I often find myself needing a different unit, in which case CSS is 
> the only option.
> 
> Perhaps however this is a different issue, as it would apply to much more 
> than just borders.
> 
> --John
> 
> On 08/06/2021 17:29, Scott Palmer wrote:
>> +1 for having a variant that takes a width. Colour, width, and radius are 
>> the main parameters I need, so a variant that takes all three would help:
>> 
>> Border.stroke(Paint p, double width, double radii)
>> 
>> (Though to be honest for my larger projects most of the time this stuff is 
>> set in a style sheet.  It’s smaller tools and utilities that I find this 
>> particularly tedious as the verbosity of the code becomes annoying.)
>> 
>> Scott
>> 
>>> On Jun 8, 2021, at 9:59 AM, Kevin Rushforth <kevin.rushfo...@oracle.com> 
>>> wrote:
>>> 
>>> I think that the convenience methods should just cover the most common 
>>> cases, so I'd rather skip the dotted and dashed variants. It is a good 
>>> question as to whether there ought to be a variant that takes width. I 
>>> wouldn't do that as the only method, though. I'd lean towards not taking 
>>> the width. Once you start getting into more parameters you can just use the 
>>> constructors without much more trouble.
>>> 
>>> As for the names, I have a slight preference for Border.stroke and 
>>> Background.fill.
>>> 
>>> -- Kevin
>>> 
>>> 
>>> On 6/8/2021 4:25 AM, Nir Lisker wrote:
>>>> Are dashed and dotted used frequently? I find that I only use solid unless 
>>>> I'm doing something fancy.
>>>> 
>>>> On Tue, Jun 8, 2021 at 5:21 AM Michael Strauß <michaelstr...@gmail.com 
>>>> <mailto:michaelstr...@gmail.com>> wrote:
>>>> 
>>>>   What do you think about this variation?
>>>> 
>>>>       Border.solid(Paint color, double width) ->
>>>>           new Border(new BorderStroke(color, BorderStrokeStyle.SOLID,
>>>>   null, new BorderWidths(width)))
>>>> 
>>>>       Border.dashed(Paint color, double width)  ->
>>>>           new Border(new BorderStroke(color, BorderStrokeStyle.DASHED,
>>>>   null, new BorderWidths(width)))
>>>> 
>>>>       Border.dotted(Paint color, double width) ->
>>>>           new Border(new BorderStroke(color, BorderStrokeStyle.DOTTED,
>>>>   null, new BorderWidths(width)))
>>>> 
>>>>       Background.fill(Paint color) ->
>>>>           new BackgroundFill(color, null, null)
>>>> 
>>>>   This gives developers a good deal of customizability before needing to
>>>>   fall back to using constructors.
>>>> 
>>>> 
>>>>   Am Di., 8. Juni 2021 um 03:21 Uhr schrieb Nir Lisker
>>>>   <nlis...@gmail.com <mailto:nlis...@gmail.com>>:
>>>>   >
>>>>   > The new API:
>>>>   >
>>>>   > 1. `Border.of(Paint stroke)` or `Border.stroke(Paint stroke)`
>>>>   that does
>>>>   > `new Border(new BorderStroke(Paint stroke ,
>>>>   BorderStrokeStyle.SOLID, null,
>>>>   > null));`
>>>>   > 2. `Background.of((Paint fill)` or `Background.fill(Paint fill)`
>>>>   that does
>>>>   > `new Background(new BackgroundFill(Paint fill, null, null));`
>>>>   >
>>>>   > I don't mind either name choice.
>>>>   >
>>>> 
>>> 
>> 

Reply via email to