I know that my implementation is crippled, that's why I turned to the
community. So let's not call my hack new width calculation.
I have about 160+ tabs open (Yes, I need some cleanup).
Well I do not really would like to own this one, as the time I
considered myself a hard core Swing developer was about 20 years ago.
On 1/3/20 9:10 AM, Karl Tauber wrote:
Hi Laszlo,
on my machine I have the side-effect that the tabs are wider. There is
larger empty space between the text and the close button.
The reason is that the tab text always starts with "<html>" and for
modified files the tab text contains "<b>"..."</b>".
The necessary HTML parsing could be one problem that makes it slow.
To check this, you could try to simply remove the leading "<html>",
enable the old code (setText()) and check whether it starts faster.
BTW the new width calculation does not include the width of the close
button and the label insets.
Another problem is that TabDataRenderer.getPreferredWidth() is invoked
very often. If I have only 15 files open, this method is invoked more
than 600 times on startup. And each additional open file makes it
worse. There are a lot of tableChanged events. See TabTable constructor.
Another reason could be that class TabDataRenderer.RendererPanel does
not override the methods that
javax.swing.table.DefaultTableCellRenderer for performance reasons.
Could you add following methods to TabDataRenderer.RendererPanel and
check whether it starts faster?
public void invalidate() {}
public void revalidate() {}
public void repaint(long tm, int x, int y, int width, int height) {}
public void repaint(Rectangle r) {}
public void repaint() {}
protected void firePropertyChange(String propertyName, Object
oldValue, Object newValue) {}
public void firePropertyChange(String propertyName, boolean oldValue,
boolean newValue) {}
Karl
On 03.01.2020 05:24, Laszlo Kishalmi wrote:
Dear all,
I've recently experienced that NetBeans is unresponsive for 5-10 secs
after the main screen opens. It does not really bother me as I open
NetBeans up once or twice a week. I have ~46 projects loaded (mostly
NetBeans modules).
I've tried to profile what is happening. Though right now the
profiler attachment crashes (an other issue maybe it is just on my
machine) the JVM running the profiled NetBeans in 10-15 secs, I could
get some valuable info.
It seems there is a performance bottleneck in multitabs implementation.
org.netbeans.core.multitabs.impl.TabDataRenderer.getPreferredWidth(Object)
is being called several times spending considerable amount of time
setting the text on a JLabel over and over:
https://github.com/apache/netbeans/blob/06b3e677d9ea4dbd9987c8245fe5be776e8245f8/platform/core.multitabs/src/org/netbeans/core/multitabs/impl/TabDataRenderer.java#L144
The purpose of these calls is to properly measure the width of the
rendered component.
I've tried to cheat by replacing:
renderer.label.setText( text );
renderer.label.setIcon( icon );
res = renderer.getPreferredSize().width;
With:
AffineTransform transform = new AffineTransform();
FontRenderContext frc = new FontRenderContext(transform, true, true);
Font font = renderer.label.getFont();
res = icon.getIconWidth() + renderer.label.getIconTextGap() + (int)
font.getStringBounds(text, frc).getWidth();
That, kind of, worked. The IDE starts up faster there is no visible
side-effect (yet), however I would like someone who is more into
swing to come up with a proper implementation, that handles HIDPI and
html labels. Should not be hard, I just do not have the proper
knowledge.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists