Desc: Large scenarios operate slowly at the GUI. Particularly conspicuous when dragging, as the counter image lags behind the mouse movement appreciably when on the Main map, but not in the Setup or Reinforcement views. The lags can make the whole scenario difficult to play.
Using: Windows 7, Java Version 8 Update 91, VASSAL 3.2.16, BlitzkriegLegend_v4_26.vmod.
Investigation: Seems to occur because all of the pieces on the map are being drawn on each refresh, even if not in the visible rectangle. So, the larger the scenario, then the more pieces there are and the slower it runs. Appears to come about as the module provides its own StackOverride class, which provides drawing constrained to the visible rect, but this class is being ignored by the VASSAL engine. The key code is in VASSAL.build.module.Map.drawPiecesInRegion(Graphics, Rectangle, Component) where it uses:
if(stack[i].getClass()==Stack.class)
which, I believe, should read:
if(stack[i] instanceof Stack)
I replaced the line with the line suggested and performance improved appreciably, demonstrating that the problem was algorithmic.
Notes: Hiding the units on the map and then dragging from a Reinforcement view provided the clue. As an aside, I noted that the module ‘mostly’ uses Stack(Override) for representing units, but that the portion of the engine’s draw code that draws non-Stack objects does not appear to constrain to the visible rectangle. I don’t know if this is significant.
Thus spake darrylsims:
Desc: Large scenarios operate slowly at the GUI. Particularly
conspicuous when dragging, as the counter image lags behind the mouse
movement appreciably when on the Main map, but not in the Setup or
Reinforcement views. The lags can make the whole scenario difficult to
play.
Using: Windows 7, Java Version 8 Update 91, VASSAL 3.2.16,
BlitzkriegLegend_v4_26.vmod.
Investigation: Seems to occur because all of the pieces on the map are
being drawn on each refresh, even if not in the visible rectangle. So,
the larger the scenario, then the more pieces there are and the slower
it runs. Appears to come about as the module provides its own
StackOverride class, which provides drawing constrained to the visible
rect, but this class is being ignored by the VASSAL engine. The key code
is in VASSAL.build.module.Map.drawPiecesInRegion(Graphics, Rectangle,
Component) where it uses:
if(stack[i].getClass()==Stack.class)
which, I believe, should read:
if(stack[i] instanceof Stack)
I replaced the line with the line suggested and performance improved
appreciably, demonstrating that the problem was algorithmic.
Notes: Hiding the units on the map and then dragging from a
Reinforcement view provided the clue. As an aside, I noted that the
module ‘mostly’ uses Stack(Override) for representing units, but that
the portion of the engine’s draw code that draws non-Stack objects does
not appear to constrain to the visible rectangle. I don’t know if this
is significant.
I’ve finally had a chance to have a look at this, and I concur.
Your change is correct. I think we hadn’t spotted this before because
few modules have custom code which subclasses Stack. I’ll get this
change into the next release.
–
J.