-
Notifications
You must be signed in to change notification settings - Fork 95
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
new Formatter<T> interface definition #444
Conversation
addresses issue #432 and targeted to replace other formatter definitions
b7ae9cf
to
a333601
Compare
Codecov Report
@@ Coverage Diff @@
## master #444 +/- ##
============================================
+ Coverage 53.25% 53.40% +0.14%
- Complexity 7360 7434 +74
============================================
Files 386 388 +2
Lines 40679 40840 +161
Branches 6553 6586 +33
============================================
+ Hits 21664 21809 +145
- Misses 17462 17463 +1
- Partials 1553 1568 +15
Continue to review full report at Codecov.
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Aside from the comments, there's just one overarching point I'd like to mention, which is the formatting of data sets. As the implementation is now, DataSetMath
methods expect Formatter<Number>
s and pass the name of any data set that is a formatting parameter as its formatting argument.
While this produces output that matches the current names, this also takes away the ability to supply a more general formatter that applies to datasets. In particular, if I as a user already have a Formatter<Object>
with a case for DataSet
s, which I use in a place where such a formatter is accepted, I cannot re-use that here.
I understand that representing data sets by their name should be the default behaviour and should "just work" for cases where maybe a user actually writes only a Formatter<Number>
. Therefore, I propose to special case DataSet
in Formatter#format
in the following way:
for (var i = 0; i < arguments.length; i++) {
if (test.isAssignableFrom(arguments[i].getClass())) {
formatter.setFormatByArgumentIndex(i, numberFormat);
} else if (arguments[i] instanceof DataSet) {
// If the argument is a data set, and the user-supplied
// formatting does not handle data sets (with the above case),
// default to representing data sets by name (with a
// formatter implementation `dataSetNameFormat`)
formatter.setFormatByArgumentIndex(i, dataSetNameFormat);
}
}
and accept any Formatter<? extends Object>
as the vararg parameter on the methods which is given data set objects as formatting args, but keep the current DefaultNumberFormatter
, which is a Formatter<Number>
, as the default. What do you think?
Apart from that, this PR adapts everything in DataSetMath
. Given that the two classes are very similar, MultiDimDataSetMath
should probably be included too?
chartfx-dataset/src/main/java/de/gsi/dataset/DefaultNumberFormatter.java
Show resolved
Hide resolved
@domenicquirl yes meant to make it |
818b929
to
39f0477
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good from my POV. Improves the default behavior a lot while allowing different levels of customization. 👍
addresses issue #432 and targeted to replace other formatter definitions