I love these gauges, and my application utilizes dozens of them at a time for pending tasks. When using that many instances at a time, I see slowdowns in performance that can be pinpointed to the method getUserAgentStylesheet() from the Gauge class. Rather than looking up the resource every time, would it be possible to look it up the first time as needed, and then cache the resultant String so that future invocations are quick?
As a test, I created a new Gauge sub-class and overrode the getUserAgentStylesheet() method as follows. This seemed to have resolved the performance issue for me.
public class GaugeFix extends Gauge
{
private static String userAgentStyleSheet;
public GaugeFix(SkinType skinType)
{
super(skinType);
}
@Override
public String getUserAgentStylesheet()
{
if (userAgentStyleSheet == null)
{
userAgentStyleSheet = Gauge.class.getResource("gauge.css").toExternalForm();;
}
return userAgentStyleSheet;
}
}
I love these gauges, and my application utilizes dozens of them at a time for pending tasks. When using that many instances at a time, I see slowdowns in performance that can be pinpointed to the method
getUserAgentStylesheet()
from theGauge
class. Rather than looking up the resource every time, would it be possible to look it up the first time as needed, and then cache the resultant String so that future invocations are quick?As a test, I created a new Gauge sub-class and overrode the
getUserAgentStylesheet()
method as follows. This seemed to have resolved the performance issue for me.