Hey, thanks for the nice work. I'm trying to use lets-plot in java.
It works well:
var xs = List.of(0, 0.5, 1, 2);
var ys = List.of(0, 0.25, 1, 4);
final Map<?, ?> data = Map.of("x", xs, "y", ys);
final Function1<? super GenericAesMapping, Unit> mapping = aes -> {
aes.setX("x");
aes.setY("y");
return Unit.INSTANCE;
};
var l = ggplot(data, mapping)
.plus(new geomPoint(null,
new StatOptions(StatKind.IDENTITY, Options.Companion.empty()),
new PosOptions(PosKind.IDENTITY, Options.Companion.empty()),
true, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null,
aes -> Unit.INSTANCE));
l.show();
ggsave(l, "plot.png", 2.0, null, null);
But the code is pretty heavy because the lib uses a lot of default parameter values and it results in Java in a single full signature, with all parameters present and all default values lost.
This in Java:
new geomPoint(null,
new StatOptions(StatKind.IDENTITY, Options.Companion.empty()),
new PosOptions(PosKind.IDENTITY, Options.Companion.empty()),
true, null, null, null, null, null, null, null, null, null, null, null, null, null,
null, null, null, null,
aes -> Unit.INSTANCE)
is the same as
in Kotlin.
Setting the same default values manually is prone to error and writing series of nulls is annoying.
Any chance we could consider using @JvmOverloads or generate builders?
I gave a try to @JvmOverloads, it works fine for some simple cases but it quickly gets limited as soon as a few parameter needs to be set. For instance, aes is the last parameter in geomPoint and often needs to be set, so I end up having to use the full signature.
So I guess builders are a better solution.
Hey, thanks for the nice work. I'm trying to use lets-plot in java.
It works well:
But the code is pretty heavy because the lib uses a lot of default parameter values and it results in Java in a single full signature, with all parameters present and all default values lost.
This in Java:
is the same as
in Kotlin.
Setting the same default values manually is prone to error and writing series of nulls is annoying.
Any chance we could consider using
@JvmOverloadsor generate builders?I gave a try to
@JvmOverloads, it works fine for some simple cases but it quickly gets limited as soon as a few parameter needs to be set. For instance,aesis the last parameter ingeomPointand often needs to be set, so I end up having to use the full signature.So I guess builders are a better solution.