Modify

Opened 3 months ago

Last modified 8 days ago

#23482 new defect

[PATCH] optimize the space in the history view (column width) and consider adding line wrapping

Reported by: dieterdreist Owned by: team
Priority: normal Milestone: 24.05
Component: Core Version:
Keywords: Cc:

Description (last modified by dieterdreist)

Currently I have a hard time with long values in the history view, because I have to hover over the window, often also bring it to focus, or adjust the central column width every time.

I think the column width of the first and last column could be optimized to reduce to the minimum possible width without having text overflow and give this width to the column which hasn't sufficient space to show the whole value. In particular the "since" column, showing usually only two digits, it way too wide. If this isn't enough, consider wrapping the field content over several rows. Additionally or alternatively, it could remember manually adjusted column widths.

Here is how it currently looks like:
https://josm.openstreetmap.de/attachment/ticket/23482/Screenshot%202024-02-16%20at%2012.10.54.png

Attachments (13)

Screenshot 2024-02-16 at 12.10.54.png (59.7 KB ) - added by dieterdreist 3 months ago.
current default state of history view
19007-orig-size.JPG (97.6 KB ) - added by GerdP 2 months ago.
default window size
19007-enlarged.JPG (107.5 KB ) - added by GerdP 2 months ago.
enlarged window
patched-origsize.JPG (97.5 KB ) - added by GerdP 2 months ago.
patched original window size
patched-enlarged.JPG (109.3 KB ) - added by GerdP 2 months ago.
patched enlarged window
patched-originalsize.png (166.9 KB ) - added by taylor.smock 2 months ago.
patched original window size (mac)
patched-enlarged.png (271.4 KB ) - added by taylor.smock 2 months ago.
patched enlarged window (mac)
23482-auto-adjust.patch (6.6 KB ) - added by GerdP 2 months ago.
compute minimun column based on the data
23482-2.patch (5.2 KB ) - added by GerdP 2 months ago.
improved patch that uses existing code in TableHelper and also works with modified data
unequal-columns-origsize.png (79.2 KB ) - added by Adrian 2 months ago.
Screenshot showing unequal split of right-hand pane
23482-resize.patch (1.2 KB ) - added by GerdP 2 months ago.
hack to circumvent the growing of left or right pane
23482-3.patch (1.8 KB ) - added by GerdP 2 months ago.
avoid misaligned tables
unequal-columns-patch3.png (80.4 KB ) - added by Adrian 8 weeks ago.
screenshot with 23482-3.patch

Download all attachments as: .zip

Change History (54)

by dieterdreist, 3 months ago

current default state of history view

comment:1 by dieterdreist, 3 months ago

Description: modified (diff)

comment:2 by dieterdreist, 3 months ago

Ticket #23483 has been marked as a duplicate of this ticket.

comment:3 by taylor.smock, 3 months ago

Milestone: 24.02
Summary: optimize the space in the history view (column width) and consider adding line wrapping[PATCH] optimize the space in the history view (column width) and consider adding line wrapping

I think we just have to set a max width for Since, like so:

  • src/org/openstreetmap/josm/gui/history/TagTableColumnModel.java

    diff --git a/src/org/openstreetmap/josm/gui/history/TagTableColumnModel.java b/src/org/openstreetmap/josm/gui/history/TagTableColumnModel.java
    a b  
    4142        col.setHeaderValue(tr("Since"));
    4243        col.setCellRenderer(renderer);
    4344        col.setPreferredWidth(10);
     45        col.setMaxWidth(new JLabel("v" + Integer.MAX_VALUE).getWidth());
    4446        addColumn(col);
    4547    }
    4648}

I'd apply it, but I'm having issues with the OSM API right now.

I also don't know what the "maximum" version for an object is. Integer.MAX_VALUE (2147483647) is something that we'll probably never see.

comment:4 by GerdP, 3 months ago

Doesn't work for me, new JLabel("v" + Integer.MAX_VALUE).getWidth() returns 0.

comment:5 by taylor.smock, 3 months ago

This should work better:

  • src/org/openstreetmap/josm/gui/history/TagTableColumnModel.java

    diff --git a/src/org/openstreetmap/josm/gui/history/TagTableColumnModel.java b/src/org/openstreetmap/josm/gui/history/TagTableColumnModel.java
    a b  
    4041        col = new TableColumn(COLUMN_VERSION);
    4142        col.setHeaderValue(tr("Since"));
    4243        col.setCellRenderer(renderer);
    43         col.setPreferredWidth(10);
     44        /* "." padding to avoid Since being cut off to be Sin... */
     45        col.setPreferredWidth(new JLabel(tr("Since") + ".").getMinimumSize().width);
     46        col.setMaxWidth(new JLabel("v" + Long.MAX_VALUE).getMinimumSize().width);
    4447        addColumn(col);
    4548    }
    4649}

by GerdP, 2 months ago

Attachment: 19007-orig-size.JPG added

default window size

by GerdP, 2 months ago

Attachment: 19007-enlarged.JPG added

enlarged window

by GerdP, 2 months ago

Attachment: patched-origsize.JPG added

patched original window size

by GerdP, 2 months ago

Attachment: patched-enlarged.JPG added

patched enlarged window

comment:6 by GerdP, 2 months ago

sorry for the late response. I think the original screen shot shows the history for relation r7317843.

I think the patch is an improvement. I've attached four screen shots created with a clean home dir and latest version r19007
With the original window size the difference is minimal, but the enlarged version shows the improvement.

That said the code probably doesn't work as expected as the header of the "Since" (or "Seit" in my case) column is now always truncated to "..." if the version numbers are small. I think this is because the calculated values for setPreferredWidth (22 in my case) and setMaxWidth (120) are just used as hints for the calculation of the real column widths. Since we use hardcoded value 100 for the other two columns this cannot work well.

I think the only good way to fix this is to analyse the actual data in the history:
Find the largest values for the rendered columns and the use those to set the widths.

Edit: I wonder what the longest translation for "Since" would be and if we really want to always show that untruncated.

Last edited 2 months ago by GerdP (previous) (diff)

comment:7 by dieterdreist, 2 months ago

This is a huge improvement.

For the since column: maybe there could just be an asterisk in the column head, with an explanation "* = since" somewhere else?

I think wrapping long rows would also be benefitial, truncating the content makes it very hard to compare different values.

by taylor.smock, 2 months ago

Attachment: patched-originalsize.png added

patched original window size (mac)

by taylor.smock, 2 months ago

Attachment: patched-enlarged.png added

patched enlarged window (mac)

comment:8 by GerdP, 2 months ago

Did you try the mentioned relation? It only has version up to v9.

comment:9 by taylor.smock, 2 months ago

I hate it when there is different behavior on different operating systems. Although it might be a locale issue.

@dieterdreist: fiddling with the Since column is a lot easier since we know what the absolute maximum size is.

Did you try the mentioned relation? It only has version up to v9.

Yes. It did work properly for me.

comment:10 by GerdP, 2 months ago

Your dialog is quite different. Some texts are centered where on Windows they are left aligned.

comment:11 by taylor.smock, 2 months ago

I wonder what the longest translation for "Since" would be and if we really want to always show that untruncated.

The longest I've found (on google translate) is Samoan, "Talu mai lena taimi" (roughly "since then"). There is probably a better translation, but google translate doesn't know it. Anyway, that gives us a "worst case" length.

EDIT: Moving the preferred width after setting the max width might work, if we do a Math.min call.

        col.setPreferredWidth(Math.min(new JLabel(tr("Since") + ".").getMinimumSize().width,
                col.getMaxWidth()));

Your dialog is quite different. Some texts are centered where on Windows they are left aligned.

FML. This is probably a Windows LaF difference. Metal LaF has the headers centered.

Last edited 2 months ago by taylor.smock (previous) (diff)

by GerdP, 2 months ago

Attachment: 23482-auto-adjust.patch added

compute minimun column based on the data

comment:12 by GerdP, 2 months ago

@Taylor: Please try this on Mac. It works fine on my Windows machine. The new method TagInfoViewer.adjustWidths(JTable table) should probably go somewhere else as it may be of use elsewhere. The code is based on a snippet I found here: https://tips4java.wordpress.com/2008/11/10/table-column-adjuster/

comment:13 by taylor.smock, 2 months ago

I'll give the patch a shot.

Quick comments on the patch:

  • Why are you assigning a variable that you just return in buildReferenceTable and buildCurrentTable? NVM. I missed the new fields.
  • Where did this.getWidth() / 4 come from? Shouldn't it either be 3 or 6 (why not get the number of cols for the table for that matter?)
  • What are the performance implications for objects with a lot of tags? (Might not be an issue)
Last edited 2 months ago by taylor.smock (previous) (diff)

comment:14 by GerdP, 2 months ago

  • The variables are used in adjustWidths();
  • The maxwidth stuff helps when the value column contains very long strings, without it the other two colums are too small. The width is that of TagInfoViewer which contains the two tables and my thought was that no column should take more than 1/4 of that width.

The value should probably be calculated in a different way / at a different place.

  • I saw no performance issues

comment:15 by taylor.smock, 2 months ago

Replying to GerdP:

Please try this on Mac

Seems to work.

The new method [...] should probably go somewhere else

Probably TableHelper. But it looks like we already have something similar; TableHelper.computeColumnsWidth. I'll check and see if we can replace the adjustWidths call in TagInfoViewer with it.

EDIT: It looks like it works on my machine.

Last edited 2 months ago by taylor.smock (previous) (diff)

comment:16 by GerdP, 2 months ago

Try also relation r62422, this has both many keys and long values. With the code in TableHelper the "Value" column is a bit too large and thus the header "Since" is truncated and some keys are not fully shown.

Not sure what is more important here and maybe Dieters suggestion to wrap columns is possible? It probably requires a lot of code for the diff view.

comment:17 by taylor.smock, 2 months ago

Dieters suggestion to wrap columns is possible

Technically possible if we use JTextArea. The question is how hard it will be. And we'll want to sync the height between the tables. Example:

        for (int i = 0; i < Math.min(reference.getRowCount(), current.getRowCount()); i++) {
            final int height = Math.max(reference.getRowHeight(i), current.getRowHeight(i));
            reference.setRowHeight(i, height);
            current.setRowHeight(i, height);
        }

With the code in TableHelper the "Value" column is a bit too large and thus the header "Since"

Looks like it. :(

comment:18 by GerdP, 2 months ago

Patch doesn work, it doesn't show modified tags for updated objects :(
This doesn't happen when I remove the change in HistoryBrowserDialogManager, but without that line the adjusting only happens when I click on e.g. the last row in the left pane to trigger an event. I'll try to find a better solution to trigger that.

by GerdP, 2 months ago

Attachment: 23482-2.patch added

improved patch that uses existing code in TableHelper and also works with modified data

comment:19 by taylor.smock, 2 months ago

Works for me.

comment:20 by GerdP, 2 months ago

OK, I've mapped with this patch today and did not see any problem. I've experiemented with JTextArea in the TableCellRenderer but without success so far, so I think it should be committed as a step forward.

comment:21 by GerdP, 2 months ago

In 19013/josm:

see #23482: optimize the space in the history view (column width) and consider adding line wrapping

  • use TableHelper.adjustColumnWidth to adjust column widths each time when the displayed tag data changes
  • set maximum width for the "Since" column

by Adrian, 2 months ago

Screenshot showing unequal split of right-hand pane

comment:22 by Adrian, 2 months ago

Maybe this should be a separate ticket, but it seems to make sense to address this issue at the same time. The attached screenshot shows unequal columns (r19015). This makes it difficult to compare the two versions of the object. To reproduce:
Download the history of relation 7317843.
Click on version 7 in column A and then click on version 8.
Suggested solutions:
Always split the right-hand pane into two equal halves, or
Make the widths of the two halves adjustable by the user.

comment:23 by GerdP, 2 months ago

I think I can reproduce.
The left pane is enlarged each time when the method tagInfoViewer.adjustWidths() is called. This happens when you click to compare v7 with v8 and than v8 with v9 and than again v7 with v8 and so on. Didn't recognize this before.

comment:24 by GerdP, 2 months ago

It also happens with tested version, so it seems not directly related to the changes in r19013.

comment:25 by GerdP, 2 months ago

This behaviour depends on the texts for the changeset, e.g. the comment or the imageary source.

comment:26 by Adrian, 2 months ago

This behaviour has existed for a long time. I hadn't reported it until now.

comment:27 by GerdP, 2 months ago

I've experimented with this for many hours but could not find a good solution so far.
The patch changes the layout again if the calculated layout results in unequal sizes, but that causes a flicker.

by GerdP, 2 months ago

Attachment: 23482-resize.patch added

hack to circumvent the growing of left or right pane

comment:28 by GerdP, 2 months ago

The problem also disappears with this commented line:

  • src/org/openstreetmap/josm/gui/history/VersionInfoPanel.java

     
    306306        final String text = cs != null ? cs.get(attr) : null;
    307307        // Update text, hide prefixing label if empty
    308308        if (label != null) {
    309             label.setVisible(text != null && !Utils.isStripEmpty(text));
     309            //label.setVisible(text != null && !Utils.isStripEmpty(text));
    310310        }
    311311        textArea.setText(text);
    312312        // Hide container if values of both versions are empty}}}

This code was introduced with r6865 and the related ticket #9659 mentions misaligned tables before, so maybe this was committed accidentially.

by GerdP, 2 months ago

Attachment: 23482-3.patch added

avoid misaligned tables

comment:29 by GerdP, 2 months ago

@Taylor: Can you please try this on MacOS? I see no disadvantage with the patched version. The original code may show an empty line when no source was given, the patched code shows a line with Source:
Advantage is that the column widths do not change.

by Adrian, 8 weeks ago

Attachment: unequal-columns-patch3.png added

screenshot with 23482-3.patch

comment:30 by Adrian, 8 weeks ago

I tried 23482-3.patch (with r19017) on MacOS. Mostly, it works well. I found one situation where you get unequal columns, see attached screenshot. Now the left-hand column is narrower. To reproduce:
Download the history of relation 7317843.
Click on the small triangle pointing to the right, to expand the left-hand pane to full width.
Click on the small triangle pointing to the left, to return the division between the panes to where it was.
A screen colour picker, which shows an enlarged version of the area around the cursor, and reads out the coordinates of the cursor, could be useful here (to measure elements of the history window).

I also tried with relation 62422. With the history window enlarged to full screen, the "Key" column is slightly too wide but that is not really a problem. I enlarged the window by using the window control, rather than by dragging the edges of the window. I restored the window to its original size, again using the window control. The "Since" column was then too narrow; but only if I had changed the selection in column A or B while the window was at full screen. After restoring the window, if I changed the selection again, the width of the "Since" column was reset and the version numbers reappeared. There was a similar unexpected behaviour if I moved the boundary between the "Key" and "Value" columns (by dragging the dividing line). The boundary moved back to its previous position when I changed the selection. These things are probably not important.

comment:31 by GerdP, 8 weeks ago

Thanks for testing. I didn't even recognize those small triangles! I'll try to find out why this happens.

Reg. the effects with r62422: Do you only see that with 23482-3.patch applied or also without? On Windows I don't seem to have a control to enlarge the popup to full screen (it is disabled), I can only drag the edges. I still can reproduce the too narrow "Since" column. Working on it...

Last edited 8 weeks ago by GerdP (previous) (diff)

comment:32 by GerdP, 8 weeks ago

Reg. the problem with the triangles: When I repeat the two steps the sizes are correct. Next time they are again wrong. And so on.
Still no idea what's going on there.

Regarding the too narrow "Since" column: I think we have to live with that. Users probably don't resize the dialog so that the values cannot be displayed properly.

in reply to:  31 comment:33 by Adrian, 8 weeks ago

Replying to GerdP:

Reg. the effects with r62422: Do you only see that with 23482-3.patch applied or also without? On Windows I don't seem to have a control to enlarge the popup to full screen (it is disabled), I can only drag the edges.

On MacOS, one of the window controls is disabled, the equivalent of minimising the window to the taskbar.

With r19015, without patch, with relation 62422:

When the history window opens, the "Since" columns are wide enough. After enlarging the window to full screen, the "Key" column is too wide, wider than with the patch. After restoring the window, its appearance is the same as when the window opened. If the selection is changed while the window is at full screen, the "Key" column becomes the same width as with the patch. When the window is restored after changing the selection, the columns are unequal, with the left-hand column being wider. The "Since" column is too narrow. Then change the selection, and the "Since" column becomes wider (similarly to with the patch), and the inequality between the columns becomes worse. Drag the division between the "Key" and "Value" columns, change the selection, and the division moves back to where it was, the same as with the patch.

I have discovered that the behaviour is different, the first time that the history window is opened after launching JOSM. Without the patch:
The "Since" columns are too narrow. Change the selection, and the "Since" column becomes wider, and the columns become unequal. Enlarge to full screen and then restore, and the inequality between the columns is reduced, and both "Since" columns are wide enough.
With the patch:
The "Since" columns are too narrow. Change the selection, and the "Since" columns become wider, wide enough to show all the version numbers. After enlarging the window to full screen, the "Key" column is too wide, the same as without the patch. Don't change the selection, restore the window, and its appearance is the same as before it was enlarged. If the selection is changed while the window is at full screen, the "Key" column becomes narrower, the same width as with subsequent history windows. Restore the window after changing the selection, and the "Since" columns are too narrow. Change the selection again, and the "Since" columns become wide enough.

comment:34 by GerdP, 8 weeks ago

OK, if I got that right 23482-3.patch is an approvement and it doesn't introduce further regressions? The patch only addresses the unequal sizes of left and right, not the columns widths.

The switch between full size and restored size may show the same problem as the toggle with the triangle control. It is easy to disable the triangle control, but that's not really a solution ;)
My findings so far:
The java layouter seems to have a problem with the calculation of the component widths when there is a JTextArea: Sometimes it decides to wrap the line of a long comment, sometimes it doesn't. Depending on this the left/right sides can be unequal and I've not found any way to force equal widths without also forcing a height, and the latter always results in completely wrong layout :(

comment:35 by GerdP, 8 weeks ago

I just found another problematic case: node 343494089 v5 : mapper name is extremely long and it is not wrapped.

in reply to:  34 comment:36 by Adrian, 8 weeks ago

Replying to GerdP:

OK, if I got that right 23482-3.patch is an approvement and it doesn't introduce further regressions?

Yes, it is a good improvement. And as far as I can see, it does not make anything worse. I think it is worth committing, even if you may be making more changes.

in reply to:  35 comment:37 by Adrian, 8 weeks ago

Replying to GerdP:

I just found another problematic case: node 343494089 v5 : mapper name is extremely long and it is not wrapped.

I noticed that the other piece of clickable text, the changeset number, can also be truncated. Two possible reasons why wrapping fails:

  • The text does not contain a space character.
  • It's because the text is clickable.

If it is because the text is clickable, there may be a workaround.

  • Convert the text to ordinary text.
  • Move the click functionality and the tooltip text to a new object, e.g. a small globe icon.

comment:38 by taylor.smock, 8 weeks ago

Milestone: 24.0224.03

Ticket retargeted after milestone closed

comment:39 by GerdP, 7 weeks ago

In 19020/josm:

see #23482: optimize the space in the history view (column width) and consider adding line wrapping

  • avoid misaligned tables caused by invisible fields (in many but not all cases)

comment:40 by taylor.smock, 4 weeks ago

Milestone: 24.0324.04

Ticket retargeted after milestone closed

comment:41 by taylor.smock, 8 days ago

Milestone: 24.0424.05

Ticket retargeted after milestone closed

Modify Ticket

Change Properties
Set your email in Preferences
Action
as new The owner will remain team.
as The resolution will be set. Next status will be 'closed'.
to The owner will be changed from team to the specified user.
Next status will be 'needinfo'. The owner will be changed from team to dieterdreist.
as duplicate The resolution will be set to duplicate. Next status will be 'closed'. The specified ticket will be cross-referenced with this ticket.
The owner will be changed from team to anonymous. Next status will be 'assigned'.

Add Comment


E-mail address and name can be saved in the Preferences .
 
Note: See TracTickets for help on using tickets.