[External] : Re: Convenience factories for Border and Background
Scott Palmer
swpalmer at gmail.com
Tue Jun 8 15:29:26 UTC 2021
+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.rushforth at 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ß <michaelstrau2 at gmail.com <mailto:michaelstrau2 at 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
>> <nlisker at gmail.com <mailto:nlisker at 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.
>> >
>>
>
More information about the openjfx-dev
mailing list