>>>>> "Christopher" == Christopher Coat <[email protected]> writes:

 Christopher> I just need to find the position of the view (part of the
 Christopher> frame where patches and turtles are shown) on the frame or
 Christopher> else on the total screen coordinate. (like the getX() and
 Christopher> getY() of the appFrame but only for that component.  Hope
 Christopher> it's more clear.

GUIWorkspace has a public member field called `view`, which contains an
instance of View, which is a subclass of JComponent.  Once you have the
View, you can use standard Swing calls to find out where it is on the
screen (see e.g. http://stackoverflow.com/q/2192291/86485).

You could get to the GUIWorkspace through
`org.nlogo.app.App.app().workspace()`.  That's fine for quick-and-dirty
code, but only works if unless the user is actually running the desktop
app; it won't work in an applet or embedded InterfaceComponent.  So the
more correct method would be to take your api.ExtensionContext, cast it
to nvm.ExtensionContext, call its workspace() method, and then cast the
result to GUIWorkspace.  (If the cast fails, then the model is running
headless; if you care about handling that case, you'll need some logic
that handles the failure.)

It might help us help you if you described the actual problem you are
ultimately trying to solve.  For example, it turned out that AppFrame,
which you initially asked about, was actually irrelevant.  It leads to
me wonder whether "find the position of the view" might similarly turn
out to actually be irrelevant too, if we knew what your actual ultimate
goal was.

Hope this helps,

--
Seth Tisue | Northwestern University | http://tisue.net
developer, NetLogo: http://ccl.northwestern.edu/netlogo/

-- 
You received this message because you are subscribed to the Google Groups 
"netlogo-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to