NPE during map scrolling due to off-EDT Swing calls

Perhaps you could accelerate to a peak velocity which is inversely proportional to the distance to the edge.

This only works if the mass is substantially less than that of the earth itself. Otherwise, we would have to incorporate not only elevation above sea level, but also the gravitational effects of interstellar objects. We also have to make sure that maximum velocity is well below 300,000 km/s.

  • M.

Post generated using Mail2Forum (mail2forum.com)

Thus spake “Brent Easton”:

That is a bug. I missed one of the places where I needed to stop the
Animator. I fixed it on the 3.1 branch shortly after sending the message
you were replying to.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Thus spake “Brent Easton”:

Your initial complaint was that the narrow hot zone required overly precise
mouse movement. Having the scroll velocity controlled by where in the hot
zone the mouse cursor is will require even more precise mouse movement.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Thus spake Michael Kiefte:

If you scroll at more than 300000 km/s, it should stop scrolling at start
to undo.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Thus spake Joel Uckelman:

s/at/and/


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

No,not really. My initial complaint was that you had to move the mouse into a narrow hot zone and then stop moving within that zone with no visual feedback whatsoever that you are in the correct place, the scrolling not starting until after the delay time. This would be resolved by changing the cursor to a ‘scroll’ cursor whenever it is within the Hot Zone, which I think is a must have, regardless of the Scroll dynamics we decide on.

No, I don’t believe so. Making the hot zone wider will give you more room to move and once you realise that the mouse position controls the speed, you will start to make adjustments to the mouse position without thinking to control the scroll speed. My belief is it will be very natural.

This is one of things that you have to suck and see. I don’t believe you can predict how a gui will feel in practice by reading it’s description.

If you think the idea has no merit, I will try and code up mine/Michael’s ideas when I get a chance.

Cheers,
B.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Thus spake “Brent Easton”:

It really, really shouldn’t. The Animator runs internally on a timer which
fires every 20ms. 20ms should be the same on my machine as on yours.

Try the following:

Add this method to the TimingTargetAdapter, around line 1397:

@Override
public void end() { System.out.println(t); }

Then load the Afrika II module and zoom to 50%. Scroll all the way to the
west end of the map and then drag a piece so that the map autoscrolls all
the way to the right.

This should tell us how many times the timingEvent fires. I’d like to see
if it’s about the same number of times for you as it is for me.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Thus spake “Brent Easton”:

I was looking at Acrobat Reader just now. Unfortunately it’s not very
natural to left- and middle-click simultaneously, otherwise we could use
this mechanic ourselves.

This is exactly why I think the delay should continue to be a preference,
unless we can find some way make this acceptable for everybody. I would
find a delay of less than 200ms aggravating every single time I moved a
piece near an edge.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Joel,

the answer is 72.

My use of the term ‘completely unusable’ is probably a bit strong. It works fine, scrolling super fast accross the map.

The problem is, I don’t always want to scroll fast. Sometimes that’s great, but this time, I hadn’t seen this map and I wanted to see the map slowly scroll accross in front of me.

Your current scheme gives the user no control whatsoever. There are really only two speeds - flat out and stop, it just feels out of control.

I have no problem with keeping the scroll delay as a preference.

B.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Make that 54, I was testing using my slowed down version.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Thus spake “Brent Easton”:

It’s 51 for me. Hmm.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

On May 6, 2009, at 4:04 PM, Brent Easton wrote:

I think that I would much prefer that any auto-scrolling happen in a
margin area around the map. That way there isn’t any invisible “zone”
where the auto-scroll happens. Instead there is an area off the edge
of the map content region that has auto-scrolling behavior.

I think this would be much clearer, provides visual feedback, and
doesn’t scroll unnecessarily if you are trying to place something
right near the edge of the map.

I also think it is closer to the behavior of other sorts of auto-
scroll controls such as long lists in drop-down menus that only scroll
when you go past the edge.

With a border, you could probably make do with something smaller than
the map edge zone, so perhaps 20 pixels or so would work for that.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

BUT, Consider the case where one map window overlaps another map window. You drag a unit off the edge of one map over the second map, How does VASSAL know if you are trying to scroll the first map, or trying to drop the unit on to the second map?


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Thus spake “Brent Easton”:

By the z-order of the windows, I assume.

I don’t like this for a different reason, namely that it wastes screen space.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

I’ve hacked together a scroll dynamic with a 30 pixel width and a scroll speed proportional to the distance from the viewport edge. It allows you to change between slow and fast scroll with a very natural feel. It could be better, I think the scroll speed needs to be proportional to the log of the distance to the edge.

I’m having a hell of a time getting the cursor to change though!

public static final int PREFERRED_EDGE_SCROLL_DELAY = 200;
public static final String PREFERRED_EDGE_DELAY = “PreferredEdgeDelay”; //$NON-NLS-1$
public static final int SCROLL_ZONE = 30;

/** The horizontal component of the autoscrolling vector, -1, 0, or 1. /
protected int sx;
/
* The vertical component of the autoscrolling vector, -1, 0, or 1. */
protected int sy;

protected int dx, dy;

/**

  • Begin autoscrolling the map if the given point is within the given
  • distance from a viewport edge.
  • @param evtPt
  • @param dist
    */
    public void scrollAtEdge(Point evtPt, int dist) {
    final Rectangle vrect = scroll.getViewport().getViewRect();

final int px = evtPt.x - vrect.x;
final int py = evtPt.y - vrect.y;

// determine scroll vector
sx = 0;
if (px < dist && px >= 0) {
sx = -1;
dx = dist - px;
}
else if (px < vrect.width && px >= vrect.width - dist) {
sx = 1;
dx = dist - (vrect.width - px);
}
//sx = ? -1 :
// (px < vrect.width && px >= vrect.width - dist ? 1 : 0);

sy = 0;
if (py < dist && py >= 0) {
sy = -1;
dy = dist - py;
}
else if (py < vrect.height && py >= vrect.height - dist) {
sy = 1;
dy = dist - (vrect.height - py);
}

// Slow it down.
dx = dx / 2;
dy = dy / 2;
//sy = py < dist && py >= 0 ? -1 :
// (py < vrect.height && py >= vrect.height - dist ? 1 : 0);

// start autoscrolling if we have a nonzero scroll vector
if (sx != 0 || sy != 0) {
if (!scroller.isRunning()) {
scroller.setStartDelay((Integer)
GameModule.getGameModule().getPrefs().getValue(PREFERRED_EDGE_DELAY));
scroller.start();
}
}
else {
if (scroller.isRunning()) scroller.stop();
}
}

/** The animator which controls autoscrolling. */
protected Animator scroller = new Animator(Animator.INFINITE,
new TimingTargetAdapter() {
private int t;

@Override
public void timingEvent(float fraction) {
// Follow the parabola x^2
//final int delta = 2*(t++);
//scroll(sxdelta, sydelta);
scroll(sxdx, sydy);

// Check whether we have hit an edge
final Rectangle vrect = scroll.getViewport().getViewRect();

if ((sx == -1 && vrect.x == 0) ||
(sx == 1 && vrect.x + vrect.width >= theMap.getWidth())) sx = 0;

if ((sy == -1 && vrect.y == 0) ||
(sy == 1 && vrect.y + vrect.height >= theMap.getHeight())) sy = 0;

// Stop if the scroll vector is zero
if (sx == 0 && sy == 0) scroller.stop();
}

@Override
public void begin() { t = 1; }
}
);


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Thus spake “Brent Easton”:

I tried getting the cursor to change also. The DnD stuff interferes with it.
I have a different idea about what should happen for visual feedback which
doesn’t involve changing the cursor, which I’ll try over the weekend.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

On May 7, 2009, at 3:02 PM, Brent Easton wrote:

Because the margin is part of the first map’s window. So if you move
past the margin, you then get into the second map.

It does have the drawback that Joel noted of consuming screen real
estate, although with a separate margin, it could perhaps be a little
smaller than what you would want for a sensitive zone around the edge
of the map.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

On May 8, 2009, at 2:41 AM, Joel Uckelman wrote:

Well, perhaps the auto-scroll zone should always be marked, say with a
thin, possibly dotted line near the edge of the window? Is that the
solution you are thinking of?


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

Thus spake Thomas Russ:

Not exactly. What I have in mind is making a translucent strip along the
map edge which shows up if you hover there.


J.


Messages mailing list
Messages@forums.vassalengine.org
forums.vassalengine.org/mailman/ … engine.org

Post generated using Mail2Forum (mail2forum.com)

So everyone knows, CounterDetailViewer had the same problem as Map w/r/t
incorrect use of a Thread to call Swing methods. I replaced the Thread in
CounterDetailViewer with a Timer, in 3.1@5588. This should result in no
noticeable difference in the behavior of CounterDetailViewer, other than
that you’ll never see an NPE due to an off-EDT Swing call now.

If I’m wrong and the fix does alter the behavior of CounterDetailViewer
for you, please tell me so we can review the changes I made.