Services & Resources / Wolfram Forums
-----
 /
MathGroup Archive
2001
*January
*February
*March
*April
*May
*June
*July
*August
*September
*October
*November
*December
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2001

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: J/Link MathCanvas/Graphics/Interaction

  • To: mathgroup at smc.vnet.net
  • Subject: [mg27214] Re: J/Link MathCanvas/Graphics/Interaction
  • From: tgayley at wolfram.com (Todd Gayley)
  • Date: Mon, 12 Feb 2001 03:20:52 -0500 (EST)
  • Organization: Wolfram Research, Inc.
  • References: <96096k$oem@smc.vnet.net>
  • Sender: owner-wri-mathgroup at wolfram.com

On 9 Feb 2001 03:19:32 -0500, murphee <werner.schuster at netway.at> wrote:

>yo Group (especially Todd Gayley),
>
>I am using the (magnificent) J/Link to do some interactive Mathematics;
>eg: Plot a graph (eg Sine curve) and a Point, and allow the user to grab 
>the Point with the
>mouse and drag it along the graph;
>
>allright, doesnt sound like much, but it's just an example to make clear 
>what I
>want to do;
>
>now, the Problem is, I can use the evaluateToImage,... methods to receive a 
>Bitmap (in GIF Format) of
>the Plot from Mathematica,
>but what I would need would be the Position of the Objects in the Plot (in 
>my example: Graph, Point)
>relative to the bitmap I receive from the evaluateToImage method,
>so I know when the mouse is "in" one of these objects (in order to know 
>when the user wants to "grab" the object);
>
>currently, I cannot get this; I would have to guess the Position of the 
>objects, but changing one Parameter in the
>Plot would make this guess useless again (and the whole thing couldn't be 
>done dynamically);
>
>I haven't yet found a way in J/Link to do this, or am I just thinking in 
>the wrong direction?
>
>if there is no simple solution available in J/Link, maybe that could be 
>something for J/Link 2.0 ...
>since you're (you = J/Link Maintainers) at the "source" of the Production 
>of the Bitmap, wouldn't it be possible
>to somehow extract/preserve these parameters and allow the user to access 
>them;
>from what I know, you use the psrender.exe programm to render the 
>PostScript output to the GIF file;
>maybe that could be a place to get that info from;
>
>I hope someone might help me here,
>Thanx in advance,
>murphee

Murphee,

Several people have asked for a similar feature. What is required is to be able to
translate coordinates in the bitmap image into coordinates of the original plot. The
notebook front end can do this, as evidenced by its ability to show plot coordinates as
you float the mouse over a plot with the Ctrl key held down.

Unfortunately, it is hard to do. The front end can do it because it has a PostScript
renderer built in. There is really no good way to get this information in Java right
now.The psrender program does not provide it, and that program will be phased out before
long anyway.

Future changes to Mathematica's graphics model will probably make this task
straightforward, but for now the best solution involves a bit of work.

One method is to render Mathematica Graphics expressions in Java yourself. You can use
FullGraphics to get Mathematica to expand a graphic into an explicit list of primitives.
Things that are normally specified only as options with values like Automatic or True
(e.g., Ticks, Axes, etc) are represented in terms of Line, Text, and other graphics
primitives. You can then send this to Java, parse through it, and draw it. An obvious
candidate for the data structure to maintain on the Java side is SVG (Scalable Vector
Graphics), an XML application. SVG would even take care of things like firing events when
objects in the image were clicked and dragged.

The SVG specification is still not finalized, and my understanding is that the APIs,
tools, and viewers for working with SVG are not universally solid yet.

It is possible that something like this will be present in a not-too-distant release of
J/Link. In the meantime, a motivated programmer could write their own implementation that
worked at least reasonably well without too much effort.


Todd Gayley
Wolfram Research


  • Prev by Date: Re: J/Link listeners
  • Next by Date: Re: JLink .. how to enable kernel tracing ?
  • Previous by thread: Re: J/Link MathCanvas/Graphics/Interaction
  • Next by thread: (long) Re: Speed Challenge