MASON-INTEREST-L Archives

September 2012

MASON-INTEREST-L@LISTSERV.GMU.EDU

Options: Use Monospaced Font
Show Text Part by Default
Show All Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Subject:
From:
Sean Luke <[log in to unmask]>
Reply To:
MASON Multiagent Simulation Toolkit <[log in to unmask]>
Date:
Tue, 4 Sep 2012 19:35:20 -0400
Content-Type:
text/plain
Parts/Attachments:
text/plain (33 lines)
Changing the viewport is not a built-in feature to MASON, and it's a little complicated: the scroll value will depend on the current scale.  And it's further complicated by multiple overlaid field portrayals.

So at the moment here's what you can do.  At any point the horizontal (and vertical) scrollbar has a minimum and a maximum, which you can get like this:

JScrollBar h = display.display.getHorizontalScrollBar();

Now you can change the bar value:

int min = h.getMinimum();
int max = h.getMaximum();
int currentValue = h.getValue();
h.setValue(  /* some value between min and max inclusive */ );

If there's no bar being displayed (maybe you're scaled way out), you'll still get min and max values but the value will always be 0 and won't change even if you set it.  No warnings though, stupid Java.

After you set the value you have to clue the JScrollPane in that its scrollbars changed.  It's too dumb to realize this :-(  The easiest way to do this is to set the JScrollPane's viewport to the inside display again.  Maybe repaint for good measure though it's probably not needed:

display.display.getViewport().setView(display.insideDisplay);
display.repaint();

At this point the field should have been scrolled to your desired location.

So the question is: what API would you like in Display2D to do this automatically for you?  We can't scroll to a value because the min and max values change depending on the degree of scaling at the moment.  Maybe scroll to a percentage/proportion value?

Sean

On Sep 4, 2012, at 1:37 PM, Joey Harrison wrote:

> We're working on a model with a very large map and investigating a tiny area within it. Every time we run the model, it takes a long time to pan, zoom, pan, zoom, ... until the right area is in view. Has anyone found a way to save a given viewport and have it come up that way on start up?
> 
> Thanks,
> Joey 

ATOM RSS1 RSS2