Overlapping data labels (MPAndroidChart) - java

If I have a lot of values with close values, the data labels overlap. For example this sequence of 14's:
Is there a way to de-clutter this somehow or "hide" labels that contribute to the clutter?

For version 3.x you can try xAxis.setLabelCount(4), but in your case may be better is xAxis.setGranularity(1f)

xAxis.setLabelsToSkip(5) it will skip five label. automatic lab

Related

Combine javafx 2 ListView and GridPane features

My target is to display an abbreviation list with two entries per line: the abbreviation and the corresponding long version. For a nice layout I used a GridPane because of the vertical alignment over all entries - it's nice to read.
But I also want to scroll to the clicked abbreviation and set the focus on it like in a ListView version of it.
For example the # on page links in good old HTML. Is there another javafx layout element I miss to achieve this?
I don't believe there is a provided control that will work for the specific scenario you are describing. However, I think one of these options might work for you...
Use the TableView control and add two columns for the information you want to show (one for the abbreviation and another for the long version). TableViews also have the scrollTo and setFocus functionality you're looking for. Here is a good resource to get you started with the Tableview control. You can also style the Tableview with CSS to look less like a table and more like a list if thats what your intention is.
The second option is to set a custom cell factory on your ListView that builds custom cells using HBoxes, VBoxes, Labels, etc. to achieve your desired look. You would also want to use the cell factory to populate each ListView cell with an object that contains both the abbreviated text and long version text. A couple good resources, 1, 2
Although I think both option will work fine, I would suggest option 1 since in option 2 you are sort of building a table type structure anyway. I hope this is helpful!

JGoodies DefaultFormBuilder - add a row dynamically

In my form there is a JComboBox, and depending on what is selected I would like to add some additional rows (labels and JTextFields) to the form just below the JComboBox and push the rest of the fields that many rows lower. Is this possible with JGoodies DefaultFormBuilder (or any other technique), and if so how?
As far as I can tell there is no proper way. So what I ended up doing was creating a JPanel for each field with a BoderLayout. Then I added the max number of fields I would ever need to the form. Then when I needed to move fields down, I would remove them from the allocated JPanel's and push them to the ones below in a loop.
Not exactly the prettiest or most elegant but I couldn't find another solution at all...

Best way to implement a selection box from a large number of entries

I have a large set of data from which the user has to select one. I'm thinking of a way to implement it (of course, in a GUI). I have a few ideas. But just thought of posting here as there may be better alternatives..
Say, user has to select a name from a large set of user base. If I simply put a text field for user to enter the name, then there can be issues like entering same name in different formats, misspelling etc...
I see two options here
Using a combo box
Using a list (Actually i'm thinking of something like a tool tip. As I cant show the whole list always due to space issues)
But combo box won't be much user friendly i guess. As the user will have to scroll around the whole list to select an entry. If the number of entries are too large, this will be
Which means, now I'm left only one option. A popping up list, which will change the content according the text user is entering in the text field. So he can type first few letters and the list will show all the entries starting from the entered text. Got my point, right?
Are there any other better to achieve this kind of need?
If I'm going to implement above, what will be the best way to follow. I'm thinking of extending the JTextField to add required functionality. Well, I'll put some method to set the popup list entries. And I'll add some actionListner to watch the text field, and control the popup list accordingly...
Autocomplete is what you are probably looking for. Google for "java swing jcombobox autocomplete" and limit results for the last couple of years to get relevant results. There will be a lot of examples and ideas on how to implement this with custom code.
I believe there is also some custom libraries like "swingx" that provide at least partial or full implementations to save time.
http://swingx.java.net/
They have released code as recently as the beginning of this years so it appears active and might have what you need.
You could take a look at SwingLab's autocomplete feature, it allows you to attach it to a JCombBox, JList or JTextComponent
use AutoComplete JComboBox/JTextField
based on Standard Java Classes
no issue with larger sets of data
no issue with Focus, BackSpace Key, Caret
for better performance to required sort the array before use
simple workaround for setStrict(true/false), restrict input to array

How to align text appended to a JScrollPane

I think the screenshot is worth a couple of paragraphs
The best way I can think of doing it is to check for the length of the string and depending give/take \t, but it just seems inelegant. Is there a simpler/better way?
I would use a JTable for this. You can put one in a JScrollPane. This will get you aligned columns automatically. Plus you will get column headers which will aid in understanding what the data means.
If you want to stick with plain text and have an upper bound on the length of fields (which you'd need to guarantee alignment), then you could use printf.

JList: Horizontal_WRAP fitted?

Hey,.. i wanna show pictures with names onit in a jList, i know it get's also in a JPanel but i'm now using a jList, doesn't matter..
My question is why does the jlist don't fit the images only in 2 horizontal 'cells' and then go one row down?
sry my english is bad and i don't know how to describe it better, but look on the picture, why does the jlist dont set the e.g. 3rd picture right next to the 2nd?
JList.HORIZONTAL_WRAP works correctly in the ListDialog JWS demo, as described in Initializing a List. I suspect a layout problem, but you might compare your code to the examples found there.
If you use HORIZONTAL_WRAP you can adjust the number of columns with setVisibleRowCount. If you want them automatically fitted to the width of the list, use 0 or something negative.

Categories